Android笔记

1.APP重启

/***
 * APP重启
 * **/
private void restartApp(Context context,Class<?> cls){ //cla:action.MAIN Activity.class
    Log.d("TAG","aaa+++  Kill myself,because of need to restart after set font size.");
    Intent intent = new Intent(context, cls);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    context.startActivity(intent);
    ((Activity)context).overridePendingTransition(0,0);
    android.os.Process.killProcess(android.os.Process.myPid());
    System.exit(0);
}

eg:  restartApp(mContext,SplashActivity.class);

上一篇:Android 服务(Service)


下一篇:第五章 界面之间的基本类型的数据传输 2.5