本文整理匯總了Java中android.os.Process.killProcess方法的典型用法代碼示例。如果您正苦於以下問題:Java Process.killProcess方法的具體用法?Java Process.killProcess怎麽用?Java Process.killProcess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.os.Process
的用法示例。
在下文中一共展示了Process.killProcess方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onVMDetected
import android.os.Process; //導入方法依賴的package包/類
@Override
public boolean onVMDetected(Context context) {
AntiVMUninstalled antiVMUninstalled = new AntiVMUninstalled();
if (antiVMUninstalled.onVMDetected(context)) {
//DO Crash
Process.killProcess(Process.myPid());
return true;
}
AntiVMCloner antiVMCloner = new AntiVMCloner();
if (antiVMCloner.onVMDetected(context)) {
//DO Crash
Process.killProcess(Process.myPid());
return true;
}
return false;
}
示例2: exitApp
import android.os.Process; //導入方法依賴的package包/類
private void exitApp() {
// 清楚圖片內存緩存
GlideImageLoader.getInstance().clearMemory(getApplicationContext());
// 清楚activity任務棧
ActivitiesManager.getInstance().popAllActivities();
// 關閉jetty服務
Intent stopIntent = new Intent(this,LocalJettyService.class);
stopService(stopIntent);
// 關閉發現小平台的service
Intent stopDescoveryIntent = new Intent(this,SSDPService.class);
stopService(stopDescoveryIntent);
Intent intent = new Intent(this, ClearImageCacheService.class);
intent.putExtra("path",mSession.getCompressPath());
startService(intent);
Intent stopProjectoinIntent = new Intent(this,StopProjectionService.class);
getApplicationContext().startService(stopProjectoinIntent);
Process.killProcess(android.os.Process.myPid());
}
示例3: restartApplication
import android.os.Process; //導入方法依賴的package包/類
/**
* 重啟App
*
* @param context application
* @param delay 當前App被殺死之後,延遲多久重新啟動。
*/
public static void restartApplication(Context context, int delay) {
Intent intent = context.getPackageManager()
.getLaunchIntentForPackage(context.getPackageName());
PendingIntent restartIntent = PendingIntent.getActivity(context.getApplicationContext(), 0
, intent, PendingIntent.FLAG_ONE_SHOT);
AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
int type = AlarmManager.ELAPSED_REALTIME_WAKEUP;
long triggerTime = SystemClock.elapsedRealtime() + delay;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
mgr.setExact(type, triggerTime, restartIntent);
} else {
mgr.set(type, triggerTime, restartIntent);
}
Process.killProcess(Process.myPid());
}
示例4: uncaughtException
import android.os.Process; //導入方法依賴的package包/類
/**
* 當UncaughtException發生時會轉入該函數來處理
*/
@Override
public void uncaughtException(Thread thread, Throwable ex) {
// if (ex==null){
// return;
// }
ex.printStackTrace();
//收集設備參數信息
collectDeviceInfo(context);
//保存日誌文件
if(activityWeakReference!=null&&activityWeakReference.get()!=null){
if(ActivityCompat.checkSelfPermission(context,Manifest.permission.WRITE_EXTERNAL_STORAGE)
!=PackageManager.PERMISSION_GRANTED){
tr=ex;
ActivityCompat.requestPermissions(activityWeakReference.get(),
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
2221);
}else {
saveCatchInfo2File(ex);
}
}
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Process.killProcess(Process.myPid());
// mDefaultHandler.uncaughtException(thread,ex);
// System.exit(1);
}
示例5: onDestroy
import android.os.Process; //導入方法依賴的package包/類
@Override
protected void onDestroy() {
//Remove the latest loaded-apk
((MyApplication) getApplication()).RemoveApk();
Log.d(TAG, "onDestroy");
Process.killProcess(Process.myPid());
super.onDestroy();
}
示例6: killMyAllProcess
import android.os.Process; //導入方法依賴的package包/類
public static void killMyAllProcess(Context context) {
//PackageManager pm = context.getPackageManager();
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
/**隻能拿到自己程序的進程列表*/
List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = am.getRunningAppProcesses();
for (ActivityManager.RunningAppProcessInfo info : runningAppProcesses) {
//L.e("logProcessInfo([context])-> " + info.processName + " " + info.pid);
if (!TextUtils.equals(info.processName, context.getPackageName()) && info.processName.contains(context.getPackageName())) {
Process.killProcess(info.pid);
}
}
Process.killProcess(Process.myPid());
}
示例7: stopItem
import android.os.Process; //導入方法依賴的package包/類
@Override
protected void stopItem(PlayableItem playableItem) {
if (appPid != 0) {
Process.killProcess(appPid);
}
}
示例8: killTinkerPatchServiceProcess
import android.os.Process; //導入方法依賴的package包/類
public static void killTinkerPatchServiceProcess(Context context) {
String serverProcessName = getTinkerPatchServiceName(context);
if (serverProcessName != null) {
for (RunningAppProcessInfo appProcess : ((ActivityManager) context.getSystemService
(ModelName.ACTIVITY)).getRunningAppProcesses()) {
if (appProcess.processName.equals(serverProcessName)) {
Process.killProcess(appProcess.pid);
}
}
}
}
示例9: onResume
import android.os.Process; //導入方法依賴的package包/類
@Override
protected void onResume() {
super.onResume();
DevicePolicyManager manager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
name = new ComponentName(this, LockReceiver.class);
if (manager.isAdminActive(name)) {
manager.lockNow();
Process.killProcess(Process.myPid());
} else {
activeManager();
}
}
示例10: killBackgroundProcesses
import android.os.Process; //導入方法依賴的package包/類
public boolean killBackgroundProcesses(String pluginPackageName) throws RemoteException {
boolean success = false;
for (RunningAppProcessInfo info : ((ActivityManager) this.mContext.getSystemService("activity")).getRunningAppProcesses()) {
if (info.pkgList != null) {
String[] pkgListCopy = (String[]) Arrays.copyOf(info.pkgList, info.pkgList.length);
Arrays.sort(pkgListCopy);
if (Arrays.binarySearch(pkgListCopy, pluginPackageName) >= 0 && info.pid != Process.myPid()) {
Log.i(TAG, "killBackgroundProcesses(%s),pkgList=%s,pid=%s", pluginPackageName, Arrays.toString(info.pkgList), Integer.valueOf(info.pid));
Process.killProcess(info.pid);
success = true;
}
}
}
return success;
}
示例11: onBackPressed
import android.os.Process; //導入方法依賴的package包/類
@Override
public void onBackPressed() {
if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
mDrawerLayout.closeDrawer(GravityCompat.START);
} else {
if (System.currentTimeMillis() - exitTime > 2000) {
Toast.makeText(this, "再按一次退出", Toast.LENGTH_SHORT).show();
exitTime = System.currentTimeMillis();
}else{
finish();
System.exit(0);
Process.killProcess(Process.myPid());
}
}
}
示例12: crash
import android.os.Process; //導入方法依賴的package包/類
public static <T> T crash(RemoteException e) throws RuntimeException {
e.printStackTrace();
if (VirtualCore.get().isVAppProcess()) {
Process.killProcess(Process.myPid());
System.exit(0);
}
throw new DeadServerException(e);
}
示例13: onDestroy
import android.os.Process; //導入方法依賴的package包/類
@Override
public void onDestroy() {
super.onDestroy();
if(musicAppPid != 0){
Process.killProcess(musicAppPid);
}
}
示例14: killAllOtherProcess
import android.os.Process; //導入方法依賴的package包/類
public static void killAllOtherProcess(Context context) {
for (RunningAppProcessInfo ai : ((ActivityManager) context.getSystemService(ModelName
.ACTIVITY)).getRunningAppProcesses()) {
if (ai.uid == Process.myUid() && ai.pid != Process.myPid()) {
Process.killProcess(ai.pid);
}
}
}
示例15: uncaughtException
import android.os.Process; //導入方法依賴的package包/類
public void uncaughtException(Thread thread, Throwable th) {
a(th);
if (this.b == null || this.b == Thread.getDefaultUncaughtExceptionHandler()) {
th.printStackTrace();
Process.killProcess(Process.myPid());
System.exit(0);
return;
}
th.printStackTrace();
this.b.uncaughtException(thread, th);
}