List of usage examples for android.os Process myPid
public static final int myPid()
From source file:com.brainasylum.andruid.UniqueIdentifierManager.java
private static boolean canReadExternalStorage(Context context) { return (context.checkPermission("android.permission.READ_EXTERNAL_STORAGE", Process.myPid(), Process.myUid()) == 0) && ((isSdCardMountedReadOnly()) || (isSdCardMounted())); }
From source file:com.qiangxi.checkupdatelibrary.dialog.CheckUpdateDialog.java
void dismissIfNeeded() { if (mOption.isForceUpdate()) { System.exit(0); Process.killProcess(Process.myPid()); } else { dismiss(); } }
From source file:at.diamonddogs.util.Utils.java
/** * Checks if the current process is a foreground process (visible by the * user)/*from w w w .ja va2 s. c o m*/ * * @param context a {@link Context} * @return <code>true</code> if the process is visible, <code>false</code> * otherwise */ public static boolean isInForground(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses(); for (RunningAppProcessInfo appProcess : appProcesses) { if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_VISIBLE && appProcess.pid == Process.myPid()) { Log.i(TAG, "visible"); return true; } } Log.i(TAG, "Running in background"); return false; }
From source file:org.esupportail.nfctagdroid.NfcTacDroidActivity.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle(R.string.exit) .setMessage(R.string.msg_exit) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override//from w w w. j a v a 2 s . co m public void onClick(DialogInterface dialog, int which) { finish(); Process.killProcess(Process.myPid()); System.exit(1); } }).setNegativeButton(R.string.no, null).show(); } return true; }
From source file:org.catnut.ui.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // open or close the drawer if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }//from ww w.j ava2 s . c om switch (item.getItemId()) { // killapp??back???back stack case R.id.logout: new AlertDialog.Builder(this).setMessage(getString(R.string.logout_confirm)) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Process.killProcess(Process.myPid()); } }).setNegativeButton(android.R.string.no, null).show(); break; // ??? case R.id.cancellation: new AlertDialog.Builder(this).setMessage(getString(R.string.cancellation_confirm)) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mApp.invalidateAccessToken(); Intent intent = new Intent(MainActivity.this, HelloActivity.class); // ?back stack intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }).setNegativeButton(android.R.string.no, null).show(); break; case R.id.pref: startActivity(SingleFragmentActivity.getIntent(this, SingleFragmentActivity.PREF)); break; case R.id.action_compose: startActivity(new Intent(this, ComposeTweetActivity.class)); break; case R.id.fantasy: startActivity(new Intent(this, HelloActivity.class).putExtra(HelloActivity.TAG, HelloActivity.TAG)); break; case R.id.plugins: switch2Plugins(null); break; case R.id.action_refresh_news_count: fetchNews(); break; default: break; } return super.onOptionsItemSelected(item); }
From source file:org.zywx.wbpalmstar.engine.EBrowserActivity.java
@Override protected void onDestroy() { EUtil.loge("App onDestroy"); super.onDestroy(); reflectionPluginMethod("onActivityDestroy"); Process.killProcess(Process.myPid()); }
From source file:de.dmxcontrol.activity.ControlActivity.java
@Override public void onBackPressed() { if (oldState != ActionSelectorFragment.STATE_DEVICE_PANEL) { onUpdateActionView(true, ActionSelectorFragment.STATE_DEVICE_PANEL); } else {/*w w w. j a v a 2 s.c om*/ AlertDialog alertDialog = new AlertDialog.Builder(this).setTitle(R.string.about_title) .setIcon(R.drawable.androidmann_neu).setTitle(getString(R.string.ask_close)) .setMessage(getString(R.string.ask_close_app)) .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Process.killProcess(Process.myPid()); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).create(); alertDialog.show(); } }
From source file:com.example.alyshia.customsimplelauncher.MainActivity.java
@Override protected void onDestroy() { super.onDestroy(); unregisterReceiver(kioskReceiver);//from w ww . jav a 2s.c o m if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { finishAndRemoveTask(); } mKnoxThread.quit(); Process.killProcess(Process.myPid()); }
From source file:org.zywx.wbpalmstar.engine.EBrowserActivity.java
private final void loadResError() { AlertDialog.Builder dia = new AlertDialog.Builder(this); dia.setTitle(EResources.display_dialog_error); dia.setMessage(EResources.display_init_error); dia.setCancelable(false);/*from www .j av a 2 s .c o m*/ dia.setPositiveButton(EResources.display_confirm, new OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); Process.killProcess(Process.myPid()); } }); dia.create(); dia.show(); }
From source file:org.anothermonitor.ServiceReader.java
@SuppressWarnings("unchecked") private void record() { if (mW == null) { File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Monitor"); dir.mkdirs();/*from w w w .j a v a 2s . c o m*/ mFile = new File(dir, new StringBuilder().append(getString(R.string.app_name)).append("Record-") .append(getDate()).append(".csv").toString()); try { mW = new BufferedWriter(new FileWriter(mFile)); } catch (IOException e) { notifyError(e); return; } } try { if (topRow) { StringBuilder sb = new StringBuilder().append(getString(R.string.app_name)) .append(" Record,Starting date and time:,").append(getDate()) .append(",Read interval (ms):,").append(intervalRead).append(",MemTotal (kB),") .append(memTotal).append("\nTotal CPU usage (%),Monitor (Pid ").append(Process.myPid()) .append(") CPU usage (%),Monitor Memory (kB)"); if (mListSelected != null && !mListSelected.isEmpty()) for (Map<String, Object> p : mListSelected) sb.append(",").append(p.get(C.pAppName)).append(" (Pid ").append(p.get(C.pId)) .append(") CPU usage (%)").append(",").append(p.get(C.pAppName)) .append(" Memory (kB)"); sb.append( ",,Memory used (kB),Memory available (MemFree+Cached) (kB),MemFree (kB),Cached (kB),Threshold (kB)"); mW.write(sb.toString()); mNM.notify(10, mNotificationRecord); topRow = false; } StringBuilder sb = new StringBuilder().append("\n").append(cpuTotal.get(0)).append(",") .append(cpuAM.get(0)).append(",").append(memoryAM.get(0)); if (mListSelected != null && !mListSelected.isEmpty()) for (Map<String, Object> p : mListSelected) { if (p.get(C.pDead) != null) sb.append(",DEAD,DEAD"); else sb.append(",").append(((List<Integer>) p.get(C.pFinalValue)).get(0)).append(",") .append(((List<Integer>) p.get(C.pTPD)).get(0)); } sb.append(",").append(",").append(memUsed.get(0)).append(",").append(memAvailable.get(0)).append(",") .append(memFree.get(0)).append(",").append(cached.get(0)).append(",").append(threshold.get(0)); mW.write(sb.toString()); } catch (IOException e) { notifyError(e); return; } }