It sets the FLAG_ACTIVITY_CLEAR_TOP flag on the Intent along with the HomeActivity. This flag launches a new instance of the activity if it isn’t currently running, and closes all the activities on top of it.
public static void goHome( Context ctx ) { if ( ! ( ctx instanceof HomeActivity ) ) { Intent intent = new Intent( ctx, HomeActivity.class ); intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP ); ctx.startActivity( intent ); } }
No comments:
Post a Comment