本页文章导读:
▪mac快捷键总结 mac快捷键小结
Command-Shift-3: 将整个屏幕拍下并保存到桌面。Command-Shift-Control-3:将整个屏幕拍下并保存到剪贴板,你可以Command+V直接粘贴到如Photoshop等软件中编辑。Command-Shift-4:将屏幕的一部.........
▪ 获取跟判断正在运行的服务 获取和判断正在运行的服务
void getTask() {ActivityManager activityManager;try {activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);arylistTask =new ArrayList<String>();List<ActivityManager.RunningTaskInf.........
▪ View兑现涂鸦、撤销以及重做功能 View实现涂鸦、撤销以及重做功能
eoe上既然看见了,就备份一下,少许更改了部分代码:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import jav.........
[1]mac快捷键总结
来源: 互联网 发布时间: 2014-02-18
mac快捷键小结
Command-Shift-3: 将整个屏幕拍下并保存到桌面。
Command-Shift-Control-3:将整个屏幕拍下并保存到剪贴板,你可以Command+V直接粘贴到如Photoshop等软件中编辑。
Command-Shift-4:将屏幕的一部分拍下并保存到桌面。按下这个组合键后,光标会变为一个十字,可以拖拉来选取拍摄区域。
Command-Shift-Control-4:将屏幕的一部分拍下并保存到剪贴板。
Command-Shift-4再按空格键:这时光标会变为一个照相机图标,点击可拍下当前窗口或菜单或Dock以及图标等,只要将照相机图标移动到不同区域(有效区域会显示为浅蓝色)点击。
Command-Shift-Control-4再按空格键:将选取的窗口或其他区域的快照保存到剪贴板
正在慢慢收集中......
Command-Shift-3: 将整个屏幕拍下并保存到桌面。
Command-Shift-Control-3:将整个屏幕拍下并保存到剪贴板,你可以Command+V直接粘贴到如Photoshop等软件中编辑。
Command-Shift-4:将屏幕的一部分拍下并保存到桌面。按下这个组合键后,光标会变为一个十字,可以拖拉来选取拍摄区域。
Command-Shift-Control-4:将屏幕的一部分拍下并保存到剪贴板。
Command-Shift-4再按空格键:这时光标会变为一个照相机图标,点击可拍下当前窗口或菜单或Dock以及图标等,只要将照相机图标移动到不同区域(有效区域会显示为浅蓝色)点击。
Command-Shift-Control-4再按空格键:将选取的窗口或其他区域的快照保存到剪贴板
正在慢慢收集中......
[2] 获取跟判断正在运行的服务
来源: 互联网 发布时间: 2014-02-18
获取和判断正在运行的服务
void getTask() {
ActivityManager activityManager;
try {
activityManager = (ActivityManager) this
.getSystemService(ACTIVITY_SERVICE);
arylistTask =
new ArrayList<String>();
List<ActivityManager.RunningTaskInfo> mRunningTasks =
activityManager.getRunningTasks(30); //30表示获取的最大数
/* 以循环及baseActivity方式取得任务名称与ID */
for (RunningTaskInfo amTask : mRunningTasks)
{
Log.d("TaskInfo", amTask.baseActivity.getClassName()+"("+amTask.id+")");
}
//获取服务
List<RunningServiceInfo> mserviceTasks =
activityManager.getRunningServices(30);
/* 以循环方式取得任务名称与ID */
for (RunningServiceInfo serinfo : mserviceTasks)
{
Log.d("TaskServerInfo", serinfo.process+"("+serinfo.pid+")");
}
}
catch (Exception e)
{
}
--------------String serviceinfo;
String serviceClassName;//需要判断服务的名称
ActivityManager am=(ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
//获取后台运行的服务,参数50代表获取的最大数,可以自定义
List<RunningServiceInfo> runninglist = am.getRunningServices(50);
//将获取到的服务名称赋值给字符串serviceinfo
for(RunningServiceInfo info :runninglist){
serviceinfo+=info.service.getClassName()+"...\n";
}
//for (int i = 0; i < runninglist.size(); i++) {
// serviceinfo+=list.get(i).service.getClassName()+"...\n";
// }
//判断服务是否运行
for(int i=0;i<runninglist.size();i++){
if(serviceClassName.equals(runninglist.get(i).service.getClassName())){
//serviceClassName服务正在运行
...
}
}
--------------
import java.util.Iterator; import java.util.List; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager.RunningServiceInfo; import android.app.Service; imp
Android获取正在运行的服务,如下代码:
import java.util.Iterator; import java.util.List; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager.RunningServiceInfo; import android.app.Service; import android.content.ComponentName; import android.content.Context; import android.os.Bundle; public class getRunningServicesInfo extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); getRunningServicesInfo(this); } //RunningServicesInfo public static String getRunningServicesInfo(Context context) { StringBuffer serviceInfo = new StringBuffer(); final ActivityManager activityManager = (ActivityManager) context .getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> services = activityManager.getRunningServices(100); Iterator<RunningServiceInfo> l = services.iterator(); while (l.hasNext()) { RunningServiceInfo si = (RunningServiceInfo) l.next(); serviceInfo.append("pid: ").append(si.pid); serviceInfo.append("\nprocess: ").append(si.process); serviceInfo.append("\nservice: ").append(si.service); serviceInfo.append("\ncrashCount: ").append(si.crashCount); serviceInfo.append("\nclientCount: ").append
(si.clientCount); serviceInfo.append("\nactiveSince: ").append(si.activeSince); serviceInfo.append("\nlastActivityTime: ").append(si.lastActivityTime); serviceInfo.append("\n\n"); } System.out.println(serviceInfo.toString()); return serviceInfo.toString(); } }
-----------http://hbczzsw.iteye.com/blog/746177
void getTask() {
ActivityManager activityManager;
try {
activityManager = (ActivityManager) this
.getSystemService(ACTIVITY_SERVICE);
arylistTask =
new ArrayList<String>();
List<ActivityManager.RunningTaskInfo> mRunningTasks =
activityManager.getRunningTasks(30); //30表示获取的最大数
/* 以循环及baseActivity方式取得任务名称与ID */
for (RunningTaskInfo amTask : mRunningTasks)
{
Log.d("TaskInfo", amTask.baseActivity.getClassName()+"("+amTask.id+")");
}
//获取服务
List<RunningServiceInfo> mserviceTasks =
activityManager.getRunningServices(30);
/* 以循环方式取得任务名称与ID */
for (RunningServiceInfo serinfo : mserviceTasks)
{
Log.d("TaskServerInfo", serinfo.process+"("+serinfo.pid+")");
}
}
catch (Exception e)
{
}
--------------String serviceinfo;
String serviceClassName;//需要判断服务的名称
ActivityManager am=(ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
//获取后台运行的服务,参数50代表获取的最大数,可以自定义
List<RunningServiceInfo> runninglist = am.getRunningServices(50);
//将获取到的服务名称赋值给字符串serviceinfo
for(RunningServiceInfo info :runninglist){
serviceinfo+=info.service.getClassName()+"...\n";
}
//for (int i = 0; i < runninglist.size(); i++) {
// serviceinfo+=list.get(i).service.getClassName()+"...\n";
// }
//判断服务是否运行
for(int i=0;i<runninglist.size();i++){
if(serviceClassName.equals(runninglist.get(i).service.getClassName())){
//serviceClassName服务正在运行
...
}
}
--------------
import java.util.Iterator; import java.util.List; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager.RunningServiceInfo; import android.app.Service; imp
Android获取正在运行的服务,如下代码:
import java.util.Iterator; import java.util.List; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager.RunningServiceInfo; import android.app.Service; import android.content.ComponentName; import android.content.Context; import android.os.Bundle; public class getRunningServicesInfo extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); getRunningServicesInfo(this); } //RunningServicesInfo public static String getRunningServicesInfo(Context context) { StringBuffer serviceInfo = new StringBuffer(); final ActivityManager activityManager = (ActivityManager) context .getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> services = activityManager.getRunningServices(100); Iterator<RunningServiceInfo> l = services.iterator(); while (l.hasNext()) { RunningServiceInfo si = (RunningServiceInfo) l.next(); serviceInfo.append("pid: ").append(si.pid); serviceInfo.append("\nprocess: ").append(si.process); serviceInfo.append("\nservice: ").append(si.service); serviceInfo.append("\ncrashCount: ").append(si.crashCount); serviceInfo.append("\nclientCount: ").append
(si.clientCount); serviceInfo.append("\nactiveSince: ").append(si.activeSince); serviceInfo.append("\nlastActivityTime: ").append(si.lastActivityTime); serviceInfo.append("\n\n"); } System.out.println(serviceInfo.toString()); return serviceInfo.toString(); } }
-----------http://hbczzsw.iteye.com/blog/746177
[3] View兑现涂鸦、撤销以及重做功能
来源: 互联网 发布时间: 2014-02-18
View实现涂鸦、撤销以及重做功能
eoe上既然看见了,就备份一下,少许更改了部分代码:
eoe上既然看见了,就备份一下,少许更改了部分代码:
import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Path; import android.graphics.Bitmap.CompressFormat; import android.os.Environment; import android.view.MotionEvent; import android.view.View; /** * View实现涂鸦、撤销以及重做功能 */ public class TuyaView extends View { private Bitmap mBitmap; private Canvas mCanvas; private Path mPath; private Paint mBitmapPaint;// 画布的画笔 private Paint mPaint;// 真实的画笔 private float mX, mY;// 临时点坐标 private static final float TOUCH_TOLERANCE = 4; // 保存Path路径的集合,用List集合来模拟栈 private static List<DrawPath> savePath; // 记录Path路径的对象 private DrawPath dp; private int screenWidth, screenHeight; private class DrawPath { public Path path;// 路径 public Paint paint;// 画笔 } public TuyaView(Context context, int w, int h) { super(context); screenWidth = w; screenHeight = h; mBitmap = Bitmap.createBitmap(screenWidth, screenHeight, Bitmap.Config.ARGB_8888); // 保存一次一次绘制出来的图形 mCanvas = new Canvas(mBitmap); mBitmapPaint = new Paint(Paint.DITHER_FLAG); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND);// 设置外边缘 mPaint.setStrokeCap(Paint.Cap.ROUND);// 形状 mPaint.setStrokeWidth(5);// 画笔宽度 savePath = new ArrayList<DrawPath>(); } @Override public void onDraw(Canvas canvas) { canvas.drawColor(0xFFAAAAAA); // 将前面已经画过得显示出来 canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint); if (mPath != null) { // 实时的显示 canvas.drawPath(mPath, mPaint); } } private void touch_start(float x, float y) { mPath.moveTo(x, y); mX = x; mY = y; } private void touch_move(float x, float y) { float dx = Math.abs(x - mX); float dy = Math.abs(mY - y); if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) { // 从x1,y1到x2,y2画一条贝塞尔曲线,更平滑(直接用mPath.lineTo也是可以的) mPath.quadTo(mX, mY, (x + mX) / 2, (y + mY) / 2); mX = x; mY = y; } } private void touch_up() { mPath.lineTo(mX, mY); mCanvas.drawPath(mPath, mPaint); //将一条完整的路径保存下来(相当于入栈操作) savePath.add(dp); mPath = null;// 重新置空 } /** * 撤销的核心思想就是将画布清空, * 将保存下来的Path路径最后一个移除掉, * 重新将路径画在画布上面。 */ public void undo() { if (savePath != null && savePath.size() > 0) { savePath.remove(savePath.size() - 1); redrawOnBitmap(); } } /** * 重做 */ public void redo(){ if (savePath != null && savePath.size() > 0) { savePath.clear(); redrawOnBitmap(); } } private void redrawOnBitmap(){ mBitmap = Bitmap.createBitmap(screenWidth, screenHeight, Bitmap.Config.ARGB_8888); mCanvas.setBitmap(mBitmap);// 重新设置画布,相当于清空画布 Iterator<DrawPath> iter = savePath.iterator(); while (iter.hasNext()) { DrawPath drawPath = iter.next(); mCanvas.drawPath(drawPath.path, drawPath.paint); } invalidate();// 刷新 } @Override public boolean onTouchEvent(MotionEvent event) { float x = event.getX(); float y = event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: // 每次down下去重新new一个Path mPath = new Path(); //每一次记录的路径对象是不一样的 dp = new DrawPath(); dp.path = mPath; dp.paint = mPaint; touch_start(x, y); invalidate(); break; case MotionEvent.ACTION_MOVE: touch_move(x, y); invalidate(); break; case MotionEvent.ACTION_UP: touch_up(); invalidate(); break; } return true; } public void saveToSDCard(){ String fileUrl = Environment.getExternalStorageDirectory() .toString() + "/android/data/test.png"; try { FileOutputStream fos = new FileOutputStream(new File(fileUrl)); mBitmap.compress(CompressFormat.PNG, 100, fos); fos.flush(); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
import android.app.Activity; import android.os.Bundle; import android.util.DisplayMetrics; import android.util.Log; import android.view.KeyEvent; public class TuyaActivity extends Activity { private TuyaView tuyaView = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); tuyaView = new TuyaView(this, dm.widthPixels, dm.heightPixels); setContentView(tuyaView); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) {// 返回键 tuyaView.undo(); return true; }else if(keyCode == KeyEvent.KEYCODE_MENU){//MENU tuyaView.redo(); return true; } return super.onKeyDown(keyCode, event); } }
1 楼
yawin
2012-02-20
学习了 ,
最新技术文章: