ActivityManager killBackgroundProcesses - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ActivityManager killBackgroundProcesses method.

This code example shows how to use the following methods:killBackgroundProcesses, restartPackage
 
        //ɱ��Application 
        String packName = context.getPackageName();
        ActivityManager activityMgr = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        //todo: ��ҪȨ��<uses-permission android:name="android.permission.RESTART_PACKAGES" /> 
        activityMgr.restartPackage(packName);
        //todo: ��ҪȨ�� <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/> 
        activityMgr.killBackgroundProcesses(packName);
        android.os.Process.killProcess(android.os.Process.myPid());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:killBackgroundProcesses
This code example shows how to use the following methods:killBackgroundProcesses
This code example shows how to use the following methods:killBackgroundProcesses, restartPackage
			} 
			System.gc();
			ActivityManager activityManager = (ActivityManager) mContext
					.getSystemService(Context.ACTIVITY_SERVICE);
 
			activityManager.restartPackage(mContext.getPackageName());
			activityManager.killBackgroundProcesses(mContext.getPackageName());
			android.os.Process.killProcess(android.os.Process.myPid());
 
			System.exit(0);
		} 
	} 
 
	private boolean handleException(Throwable ex) {
		if (ex == null) {
			return true; 
		} 
		final String msg = ex.getLocalizedMessage();
		// 使用Toast来显示异常信息 
		// new Thread() { 
4
CodeRank
This code example shows how to use the following methods:killBackgroundProcesses
		_internalInstance.startActivity(launchHome);
 
		// post delay runnable(waiting for home application launching) 
		new Handler().postDelayed(new Runnable() {
			public void run() { 
				am.killBackgroundProcesses(_internalInstance.getPackageName());
			} 
		}, 2000); 
	} 
	 
	/** 
	 * Worker ThreadPool 
	 */ 
	private ExecutorService workExecutor;
	private ExecutorService statsWorkExecutor; // 통계용 worker. single thread
	 
	private Handler handler;
	private Handler backgroundHandler;
	private HandlerThread backgroundHandlerThread;
 
4
CodeRank
This code example shows how to use the following methods:killBackgroundProcesses, restartPackage
					@Override 
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub 
						ActivityManager activityMgr = (ActivityManager) mContext
								.getSystemService(Context.ACTIVITY_SERVICE);
						activityMgr.restartPackage(mContext.getPackageName());
						activityMgr.killBackgroundProcesses(mContext
								.getPackageName());
						android.os.Process.killProcess(android.os.Process
								.myPid());
						System.exit(0);
					} 
				}).create();
		alertDialog.show();
		index = 1;
	} 
 
} 
5
CodeRank
This code example shows how to use the following methods:killBackgroundProcesses
		return connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isConnectedOrConnecting();
	} 
 
	@Override 
	public void killProcess(String packageName) {
		activityManager.killBackgroundProcesses(packageName);
	} 
 
	@Override 
	public boolean isProcessRunning(String packageName) {
		if (packageName == null)
			return false; 
		List<ActivityManager.RunningAppProcessInfo> list = activityManager.getRunningAppProcesses();
		if (list != null) {
			for (int i = 0; i < list.size(); ++i) {
				if (packageName.equals(list.get(i).processName))
					return true; 
			} 
		} 
		return false; 
3
CodeRank
This code example shows how to use the following methods:killBackgroundProcesses
	} 
 
	public static final void terminateApp(AppItem app, Context ctx) {
		ActivityManager am = (ActivityManager) ctx
				.getSystemService(ctx.ACTIVITY_SERVICE);
		am.killBackgroundProcesses(app.getPackageName());
	} 
 
	public static final Boolean isRunning(AppItem app, Context ctx) {
		ActivityManager am = (ActivityManager) ctx
				.getSystemService(ctx.ACTIVITY_SERVICE);
		for (RunningAppProcessInfo info : am.getRunningAppProcesses()) {
			if (app.getProcessName().equals(info.processName)) {
				return true; 
			} 
		} 
		return false; 
	} 
 
	public static final List<AppItem> getAppList(Context ctx) {
4
CodeRank
This code example shows how to use the following methods:killBackgroundProcesses
			 
			String pkg=extras.getString("pkg");
			 
			ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
 
			am.killBackgroundProcesses(pkg);
		} 
		else 
			Log.e("SetecAstronomy","dunno what to do - exitting");
		 
		 
	} 
 
	@Override 
	protected void onResume() { 
		super.onResume(); 
		finish();
	} 
 
} 
5
CodeRank
This code example shows how to use the following methods:killBackgroundProcesses
	 */ 
	public void exit() { 
 
		if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.ECLAIR_MR1) {
			ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
			am.killBackgroundProcesses(getPackageName());
 
		} else { 
			android.os.Process.killProcess(android.os.Process.myPid());
		} 
 
	} 
	 
	/** 
	 * 获得Context 
	 * @return 
	 */ 
	public static Context getContext(){
		return mApplication.getApplicationContext();
	} 
4
CodeRank

Related ActivityManager killBackgroundProcesses Questions & Answers:

killBackgroundProcesses Method Overview
Have the system immediately kill all background processes associated with the given package.
See Code Examples for other Android ActivityManager Methods: