本文介绍了清除缓存和数据后,Android重新启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个需要清除数据才能再次运行的应用程序. 我正在使用此清除数据,
I have an app which requires data cleaning to work better again. I am clearing data using this,
((ActivityManager)MainActivity.this.getSystemService(ACTIVITY_SERVICE)).clearApplicationUserData();但是无法重新启动应用程序.我尝试在清除数据后添加意图.但是由于应用程序在清除数据后关闭.我认为该代码无法访问.
But cannot restart the app. I tried adding intent after clearing data. But since the app closes after clearing data. I think that code is unreachable.
((ActivityManager)MainActivity.this.getSystemService(ACTIVITY_SERVICE)).clearApplicationUserData(); Toast.makeText(MainActivity.this,"Reloading...",Toast.LENGTH_SHORT).show(); startActivity(new Intent(MainActivity.this,MainActivity.class)); finish();推荐答案
调用clearApplication数据后,应用程序被杀死.这就是为什么MainActivity不被调用的原因.
After calling clearApplication data, application is killed.Thats why MainActivity doesn't called.
更多推荐
清除缓存和数据后,Android重新启动应用程序
发布评论