@Override public void onPause() { super.onPause(); BigLog.i(tag, Logging.getCurrentMethodName(), logHighlight); buttonProcessor.onStopClicked(); android.os.Process.killProcess(android.os.Process.myPid()); }
public void uncaughtException(Thread t, Throwable e) { try { // Don't re-enter -- avoid infinite loops if crash-reporting crashes. if (mCrashing) return; mCrashing = true; // Try to end profiling. If a profiler is running at this point, and we kill the // process (below), the in-memory buffer will be lost. So try to stop, which will // flush the buffer. (This makes method trace profiling useful to debug crashes.) if (ActivityThread.currentActivityThread() != null) { ActivityThread.currentActivityThread().stopProfiling(); } // Bring up crash dialog, wait for it to be dismissed ActivityManagerNative.getDefault() .handleApplicationCrash(mApplicationObject, new ApplicationErrorReport.CrashInfo(e)); } catch (Throwable t2) { try { Clog_e(TAG, "Error reporting crash", t2); } catch (Throwable t3) { // Even Clog_e() fails! Oh well. } } finally { // Try everything to make sure this process goes away. Process.killProcess(Process.myPid()); System.exit(10); } }
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i("ServiceStartArguments", "Starting #" + startId + ": " + intent.getExtras()); Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; msg.arg2 = flags; msg.obj = intent.getExtras(); mServiceHandler.sendMessage(msg); Log.i("ServiceStartArguments", "Sending: " + msg); // For the start fail button, we will simulate the process dying // for some reason in onStartCommand(). if (intent.getBooleanExtra("fail", false)) { // Don't do this if we are in a retry... the system will // eventually give up if we keep crashing. if ((flags & START_FLAG_RETRY) == 0) { // Since the process hasn't finished handling the command, // it will be restarted with the command again, regardless of // whether we return START_REDELIVER_INTENT. Process.killProcess(Process.myPid()); } } // Normally we would consistently return one kind of result... // however, here we will select between these two, so you can see // how they impact the behavior. Try killing the process while it // is in the middle of executing the different commands. return intent.getBooleanExtra("redeliver", false) ? START_REDELIVER_INTENT : START_NOT_STICKY; }
private void InstallFile(File f) { mProgress.dismiss(); if (f.length() < fileLength) { return; } try { String command = "chmod " + 777 + " " + f.getPath(); Runtime runtime = Runtime.getRuntime(); runtime.exec(command); } catch (IOException e) { e.printStackTrace(); } Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(f), "application/vnd.android.package-archive"); myActivity.startActivity(intent); try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } // // 部分机型,安装过程中,要先退出自身进程,才能安装成功。 // BaseHelper.exitProcessSilently(myActivity); // 防止下载后安装,但用户单击取消情况下的问题 // application.destroy(); // myActivity.finish(); android.os.Process.killProcess(android.os.Process.myPid()); }
@Override public void uncaughtException(Thread thread, Throwable exception) { final StringWriter stackTrace = new StringWriter(); exception.printStackTrace(new PrintWriter(stackTrace)); System.err.println(stackTrace); // 发送错误到FixBooksDirectoryActivity;开启一个activity用于处理和显示页面 Intent intent = new Intent( FBReaderIntents.Action.CRASH, new Uri.Builder().scheme(exception.getClass().getSimpleName()).build()); intent.setPackage(FBReaderIntents.DEFAULT_PACKAGE); try { myContext.startActivity(intent); } catch (ActivityNotFoundException e) { // 如果进不去,则跳转到手动提交bug页面 intent = new Intent(myContext, BugReportActivity.class); intent.putExtra(BugReportActivity.STACKTRACE, stackTrace.toString()); myContext.startActivity(intent); } if (myContext instanceof Activity) { ((Activity) myContext).finish(); } Process.killProcess(Process.myPid()); System.exit(10); }
@Override public void onStop() { super.onStop(); /** 프로세스 완전 종료 방법 */ finish(); android.os.Process.killProcess(android.os.Process.myPid()); }
@Override protected void onPostExecute(Boolean result) { String path = mContext.getString(R.string.theme) + "/" + theme + "/" + mContext.getString(R.string.wallpaper) + "/" + mContext.getString(R.string.wallpaper) + ".jpg"; Bitmap bitmap = null; try { bitmap = BitmapFactory.decodeStream(mContext.getAssets().open(path)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Drawable d = new BitmapDrawable(bitmap); setKeyguardBg(d); Intent intent = new Intent(ThemeEffectPreview.this, Launcher.class); startActivity(intent); finish(); android.os.Process.killProcess(android.os.Process.myPid()); }
public void onClick(View v) { // To kill the process hosting our service, we need to know its // PID. Conveniently our service has a call that will return // to us that information. if (mSecondaryService != null) { try { int pid = mSecondaryService.getPid(); // Note that, though this API allows us to request to // kill any process based on its PID, the kernel will // still impose standard restrictions on which PIDs you // are actually able to kill. Typically this means only // the process running your application and any additional // processes created by that app as shown here; packages // sharing a common UID will also be able to kill each // other's processes. Process.killProcess(pid); mCallbackText.setText("Killed service process."); } catch (RemoteException ex) { // Recover gracefully from the process hosting the // server dying. // Just for purposes of the sample, put up a notification. Toast.makeText(Binding.this, R.string.remote_call_failed, Toast.LENGTH_SHORT) .show(); } } }
@Override public void uncaughtException(Thread thread, Throwable ex) { try { final Writer result = new StringWriter(); final PrintWriter printWriter = new PrintWriter(result); ex.printStackTrace(printWriter); String errorReport = String.format( "[%s]\nAndroidVersion=%s\nIMEI=%s\nID=%s\n%s", new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()), VERSION.RELEASE, getIMEI(), Preference.getUsername(mAppContext), result.toString()); Log.e(LOGTAG, errorReport); File logFile = new File(mAppContext.getFilesDir(), LOG_FILE); FileWriter fw = new FileWriter(logFile, true); fw.write(errorReport); fw.flush(); fw.close(); } catch (Exception e) { e.printStackTrace(); } finally { android.os.Process.killProcess(android.os.Process.myPid()); } }
@Override public void uncaughtException(Thread arg0, Throwable arg1) { // 把错误的堆栈信息 获取出来 String errorInfo = getErrorInfo(arg1); String uuidKey = UUID.nameUUIDFromBytes(errorInfo.getBytes()).toString(); String existsException = Utils.getSharedPreferences("uncaughtException").getString(uuidKey, ""); if (!existsException.equals("")) { // -- this uncaughtException has got Debug.Log("Exception has got yet: " + errorInfo); Debug.Log("kill self() "); android.os.Process.killProcess(android.os.Process.myPid()); return; } Editor editor = Utils.getSharedPreferences("uncaughtException").edit(); editor.putString(uuidKey, "Mark"); editor.commit(); String content = DeviceInfo.getInfo(context).toString(); String msg = content + "\nStack:\n" + errorInfo; Debug.Log("uncaughtException: " + msg); errorContent = msg; // sendExceptionMsg(); }
@Override public void onDestroy() { super.onDestroy(); Log.i(TAG, "Stopping service"); stopForeground(true); if (acceptor != null) { try { acceptor.close(); } catch (IOException e) { // We don't care } } try { executor.shutdownNow(); executor.awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) { // Too bad } finally { started = false; // Unfortunately, we have no way to clean up some Binder-based callbacks // (namely IRotationWatcher) on lower API levels without killing the process, // which will allow DeathRecipient to handle it on their side. Process.killProcess(Process.myPid()); } }
public ThemeInfo getCurrentThemeInfo() { ContentResolver contentResolver = getContext().getContentResolver(); if (mCurrentThemeInfo == null) { String where = ThemeColumns.IS_APPLY + "=" + 1; Cursor cursor = contentResolver.query(ThemeColumns.CONTENT_URI, null, where, null, null); if (cursor != null) { if (cursor.moveToFirst()) { mCurrentThemeInfo = ThemeInfo.CreateFromDB(cursor); } cursor.close(); } if (mCurrentThemeInfo == null) { HomeUtils.markThemeAsApply( getContext(), HomeDataBaseHelper.getInstance(getContext()).getDefaultThemeID()); cursor = contentResolver.query(ThemeColumns.CONTENT_URI, null, where, null, null); if (cursor != null) { if (cursor.moveToFirst()) { mCurrentThemeInfo = ThemeInfo.CreateFromDB(cursor); } cursor.close(); } } if (mCurrentThemeInfo == null) { // 数据库错误,删除数据库 HomeUtils.deleteFile(getContext().getDatabasePath(ProviderUtils.DATABASE_NAME).getParent()); Process.killProcess(Process.myPid()); } } mCurrentThemeInfo.initFromXML(getContext()); return mCurrentThemeInfo; }
public static synchronized void destory() { decreaseUserCount(); if (sUserCount <= 0 && sSelf != null) { sSelf.clearUp(); sSelf = null; sIsPrepare = false; sUserCount = 0; if (sThemeAppinBilling != null) { sThemeAppinBilling.destory(); sThemeAppinBilling = null; } // 销毁HttpAdapter SimpleHttpAdapter.destory(); // 销毁HttpTool GoStoreHttpTool.destory(); // 释放ImageManager里面的资源 ImageManager.destory(); // 销毁线程池 ThreadPoolManager.destory(); // 销毁缓存管理器 CacheManager.destory(); GoStoreCacheManager.destory(); // 退出商店督促gc回收 System.gc(); // 把进程杀掉 android.os.Process.killProcess(android.os.Process.myPid()); } }
private void refreshExit(String result) { EMChatManager.getInstance().logout(); ShareSDK.stopSDK(this); Intent intent = new Intent(this, IfanService.class); stopService(intent); android.os.Process.killProcess(android.os.Process.myPid()); }
/** 结束卸载监听 */ public void stop() { if (mPid > 0) { android.os.Process.killProcess(mPid); mPid = 0; } mIsRunning = false; }
/** Checks whether LogCat Process is running or not, if not initiates the process */ private void checkLogCatProcess() { List<Integer> pids = getPID("logcat"); int pidFromDb = settings.getInt(Util.SHARED_PREFERENCES_DATA_LOGGER_PID, -1); Log.i("PhoneLab-" + getClass().getSimpleName(), "Logcat pid from database " + pidFromDb); boolean foundLogCat = false; if (pids.size() > 0) { for (int pid : pids) { // If logcat is found if (pidFromDb == pid) { Log.i("PhoneLab-" + getClass().getSimpleName(), "Logcat process found " + pid); // Process Found if (logFileThreshold()) { renameLogFiles(); } foundLogCat = true; // break; } else { Log.i("PhoneLab-" + getClass().getSimpleName(), "Killing bogus process " + pid); // Kill other bogus processes android.os.Process.killProcess(pid); // Start a new LogCat process foundLogCat = false; } } // Start LogCat if no process found if (!foundLogCat) { startLogcat(); } } else { startLogcat(); } }
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // BeeFrameworkApp.getInstance().showBug(this); // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_BACK) { if (isExit == false) { isExit = true; ToastView toast = new ToastView(getApplicationContext(), "再按一次退出程序"); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); Handler mHandler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); isExit = false; } }; mHandler.sendEmptyMessageDelayed(0, 3000); return true; } else { android.os.Process.killProcess(android.os.Process.myPid()); return false; } } return true; }
public boolean onKeyDown(int keyCode, KeyEvent event) { // exit program when key back is entered if (keyCode == KeyEvent.KEYCODE_BACK) { android.os.Process.killProcess(android.os.Process.myPid()); } return super.onKeyDown(keyCode, event); }
public void jumpToFragment(int index) { FragmentManager fragmentManager = this.getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (index == 0) { FragmentMain fragmentMain = new FragmentMain(); fragmentTransaction.replace(R.id.fragmentContainer, fragmentMain); } else if (index == 1) { FragmentOne fragmentOne = new FragmentOne(); fragmentTransaction.replace(R.id.fragmentContainer, fragmentOne); } else if (index == 2) { FragmentTwo fragmentTwo = new FragmentTwo(); fragmentTransaction.replace(R.id.fragmentContainer, fragmentTwo); } else if (index == 3) { FragmentThree fragmentThree = new FragmentThree(); fragmentTransaction.replace(R.id.fragmentContainer, fragmentThree); } else if (index == 4) { FragmentFour fragmentFour = new FragmentFour(); fragmentTransaction.replace(R.id.fragmentContainer, fragmentFour); } else if (index == 5) { FragmentAbout fragmentAbout = new FragmentAbout(); fragmentTransaction.replace(R.id.fragmentContainer, fragmentAbout); } else if (index == 6) { android.os.Process.killProcess(android.os.Process.myPid()); // 获取PID System.exit(0); } fragmentTransaction.commit(); }
private static boolean killForegroundAppInternal(Context context, int userId) throws RemoteException { final IActivityManager am = ActivityManagerNative.getDefault(); String defaultHomePackage = resolveCurrentLauncherPackage(context, userId); for (ActivityManager.RunningAppProcessInfo appInfo : am.getRunningAppProcesses()) { // Make sure it's a foreground user application (not system, root, phone, etc.) int uid = appInfo.uid, importance = appInfo.importance; if (uid < Process.FIRST_APPLICATION_UID || uid > Process.LAST_APPLICATION_UID || importance != ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { continue; } if (appInfo.pkgList != null && appInfo.pkgList.length > 0) { for (String pkg : appInfo.pkgList) { if (!pkg.equals(SYSTEMUI_PACKAGE) && !pkg.equals(defaultHomePackage)) { am.forceStopPackage(pkg, userId); return true; } } } else { Process.killProcess(appInfo.pid); return true; } } return false; }
/** 当UncaughtException发生时会转入该函数来处理 */ @Override public void uncaughtException(Thread thread, Throwable throwable) { // if (!handleException(throwable) && mLocalExceptionHandler != null) { // //如果用户没有处理则让系统默认的异常处理器来处理 // mLocalExceptionHandler.uncaughtException(thread, throwable); // } else { // try { // Thread.sleep(1000); // } catch (InterruptedException e) { // Log.e(TAG, "error : ", e); // } // //退出程序 // android.os.Process.killProcess(android.os.Process.myPid()); // System.exit(1); // // } handleException(throwable); if (mLocalExceptionHandler != null) { // 如果用户没有处理则让系统默认的异常处理器来处理 mLocalExceptionHandler.uncaughtException(thread, throwable); } else { try { Thread.sleep(2000); } catch (InterruptedException e) { Log.e(TAG, "error : ", e); } // 退出程序 android.os.Process.killProcess(android.os.Process.myPid()); System.exit(1); } }
public boolean ccKeyDown(int keyCode, KeyEvent event) { int pid = android.os.Process.myPid(); android.os.Process.killProcess(pid); Runtime r = Runtime.getRuntime(); r.gc(); System.gc(); return true; }
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(ACTION_LOCALE_CHANGED)) { android.os.Process.killProcess(android.os.Process.myPid()); System.exit(10); } }
protected void onPause() { super.onPause(); if (CNetTVChannelView.isApplicationBroughtToBackground(this.getApplicationContext()) && !CNetTvConfig.g_UserId.equals("")) { // Log.i("debug", "pause5"); android.os.Process.killProcess(android.os.Process.myPid()); } }
@Override public void onDestroy() { super.onDestroy(); mConfiguration.unregisterObserver(mObserver); // mManager.setOnCancelListener(null); android.os.Process.killProcess(android.os.Process.myPid()); System.exit(1); }
private void quitNow() { // stop background service MaintainUserStatusService.unschedule(MainActivity.this); // quit finish(); android.os.Process.killProcess(android.os.Process.myPid()); System.exit(0); }
/** 退出应用程序 */ public void AppExit(Context context) { try { finishAllActivity(); // 杀死该应用进程 android.os.Process.killProcess(android.os.Process.myPid()); System.exit(0); } catch (Exception e) { } }
@Override protected void onDestroy() { super.onDestroy(); app.getMultitalkNetworkManager().destroy(); if (logCheckTimer != null) { logCheckTimer.cancel(); } Process.killProcess(Process.myPid()); }
@Override protected void onNewIntent(Intent intent) { if (intent.getBooleanExtra("logout", false)) { // logout app.getMultitalkNetworkManager().destroy(); finish(); Process.killProcess(Process.myPid()); } }
@Override protected void onDestroy() { super.onDestroy(); // 关闭广告 AppConnect.getInstance(this).close(); // System.exit(0); // 或者下面这种方式 android.os.Process.killProcess(android.os.Process.myPid()); }