清除缓存后重新启动android应用 [英] Restart android app after cache clear

查看:327
本文介绍了清除缓存后重新启动android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在安装android应用程序更新后,我正在使用clearApplicationUserData()清除应用程序缓存.一旦上述方法运行,应用程序将立即关闭.在关闭应用程序本身后是否有重新启动应用程序的建议?

I am using clearApplicationUserData() for clear the app cache after install an update of the android application. Once above method runs, app close immediately. Any suggestion to restart the app after close the app itself?

if (Build.VERSION_CODES.KITKAT <= Build.VERSION.SDK_INT) {
    ((ActivityManager)SplashScreenActivity.this.getSystemService(ACTIVITY_SERVICE))
            .clearApplicationUserData(); 
    Toast.makeText(getApplicationContext(), "Cache cleared", Toast.LENGTH_LONG).show();
}

推荐答案

  1. 您可以创建本地广播接收器,然后会听的BroadcastReceiver .
  2. onDestroyonStop内部,呼叫您的MainActivity.
  1. you can create a local broadcast receiver and a BroadcastReceiver that would listen to it.
  2. Inside onDestroy or onStop call your MainActivity.

这篇关于清除缓存后重新启动android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆