1

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();
}
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
senps
  • 584
  • 2
  • 10
  • 30

3 Answers3

0

Alright looking at this solution it seem to have proper get way to do it. Is by adding below code to the startActivity

intent = PendingIntent.getActivity(YourApplication.getInstance().getBaseContext(), 0,
            new Intent(getIntent()), getIntent().getFlags());
Community
  • 1
  • 1
Smit
  • 2,078
  • 2
  • 17
  • 40
0
  1. you can create a local broadcast receiver and a BroadcastReceiver that would listen to it.
  2. Inside onDestroy or onStop call your MainActivity.
Nir Duan
  • 6,164
  • 4
  • 24
  • 38
0

try this:

@Override
public void onStop(){

   recreate();

}
Mahdi Nouri
  • 1,391
  • 14
  • 29