In my application I notify the user with notifications, if something special happens:
public void triggerNotification(String msg) {
notificationManag
-
I've discovered that if you use Intent contentIntent = new Intent(this, ABC.class);
this calls onCreate();
regardless of the flags set.
Use Intent contentIntent = getIntent();
to skip onCreate();
and that moves to onStart();
讨论(0)
-
The recommendation to use FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_SINGLE_TOP only partially solves the problem. The activity in the Android manifest should also have these settings applied so that launching the activity from the home screen has the same behavior. Without these properties multiple instances of the activity can be launched.
<activity android:name="foo"
android:clearTaskOnLaunch="true"
android:launchMode="singleTop"
android:label="@string/app_name">
讨论(0)
-
To bring your app to the foreground if it is running already you need to set different flags on your intent:
contentIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
For running a specific method you could just pass extra information along with the intent and interpret it in your application to decide which method to run.
讨论(0)
- 热议问题