本文整理汇总了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);
}