Use ProcessPhoenix library.
ProcessPhoenix.triggerRebirth(context);
Ensure AndroidManifest.xml
has the entry <category android:name="android.intent.category.DEFAULT" />
, else you might bump into the following exception
java.lang.IllegalStateException: Unable to determine default activity for com.luasoftware.luapass. Does an activity specify the DEFAULT category in its intent filter? at com.jakewharton.processphoenix.ProcessPhoenix.getRestartIntent(ProcessPhoenix.java:89)
<manifest ...>
<application ...>
<activity
android:name=".view.LoginActivity"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<!-- for Pheonix -->
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
References: