List of usage examples for android.os Process myPid
public static final int myPid()
From source file:Main.java
public synchronized static void quit() { finishAllActivity(); Process.killProcess(Process.myPid()); }
From source file:Main.java
private static String getCurProcessName(Context context) { int pid = Process.myPid(); ActivityManager mActivityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningAppProcessInfo appProcess : mActivityManager.getRunningAppProcesses()) { if (appProcess.pid == pid) { return appProcess.processName; }//w w w.j av a 2 s . co m } return null; }
From source file:Main.java
public static boolean checkPermission(Context context) { return context.checkPermission(Manifest.permission.CAMERA, Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED; }
From source file:Main.java
public static boolean hasPermission(Context context, String permission) { if ((context == null) || (permission == null)) { return false; }/*from w ww . java2 s. c om*/ return context.checkPermission(permission, Process.myPid(), Process.myUid()) == 0; }
From source file:Main.java
public static boolean hasPermission(Context context, String permission) { return context.checkPermission(permission, Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED; }
From source file:Main.java
public static boolean isRemoteService(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (RunningAppProcessInfo process : manager.getRunningAppProcesses()) { if (VoiceClientSerivceProcessName.equals(process.processName)) { return Process.myPid() == process.pid; }//from ww w . j av a 2s.c o m } return false; }
From source file:Main.java
private static String getProcessName(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningAppProcessInfo> infos = activityManager.getRunningAppProcesses(); int pid = Process.myPid(); RunningAppProcessInfo myInfo = null; for (RunningAppProcessInfo info : infos) { if (info.pid == pid) { myInfo = info;//from w w w. j a va2s . com break; } } return myInfo == null ? null : myInfo.processName; }
From source file:Main.java
static File make_tmpdir(Context context, SQLiteDatabase db) throws Exception { File extdir = Environment.getExternalStorageDirectory(); File tmp_top = new File(extdir, "tmp_LongText"); if (!tmp_top.exists()) { if (!tmp_top.mkdir()) throw new Exception("cannot create directory: " + tmp_top.getPath()); }/*from w ww . j av a2 s .c o m*/ if (!tmp_top.canWrite()) throw new Exception("missing permission to write to " + tmp_top.getPath()); File tmpdir; Random r = new Random(); do { tmpdir = new File(tmp_top, String.format("%d", r.nextInt())); } while (tmpdir.exists()); if (!tmpdir.mkdir()) throw new Exception("cannot create directory: " + tmp_top.getPath()); if (!tmpdir.canWrite()) throw new Exception("missing permission to write to " + tmp_top.getPath()); ContentValues v = new ContentValues(); v.put("pid", Process.myPid()); v.put("tmpdir", tmpdir.getPath()); v.put("ctime", System.currentTimeMillis()); db.insert("tmpdir", null, v); return tmpdir; }
From source file:Main.java
public static OnClickListener createKillListener() { return new OnClickListener() { public void onClick(DialogInterface dialog, int which) { Process.killProcess(Process.myPid()); }/*from ww w .j a v a 2s .c om*/ }; }
From source file:mobi.espier.lgc.LgcApp.java
public LgcApp() { sWxLiveApp = this; LogUtils.i("xsm", "........................................ app.pid=" + Process.myPid()); }