launchmode

四种LaunchMode及其使用场景

非 Y 不嫁゛ 提交于 2020-03-02 19:16:43
四种LaunchMode及其使用场景 standard 模式 这是默认模式,每次激活Activity时都会创建Activity实例,并放入当前任务栈中。使用场景:大多数Activity。 singleTop 模式 singleTop模式的Activity, 仅当该Activity已经在Task的顶部了, 才会复用. 复用时onPause, 然后onNewIntent唤起, 走onResume流程. 否则都要创建新的实例, 放进Task中。使用场景如新闻类或者阅读类App的内容页面。 singleTask 模式 如果在栈中已经有该Activity的实例,就重用该实例(会调用实例的onPause() -- onNewIntent() --onResume())。重用时,会让该实例回到栈顶,因此在它上面的实例将会被移出栈。如果栈中不存在该实例,将会创建新的实例放入栈中。使用场景如浏览器的主界面。不管从多少个应用启动浏览器,只会启动主界面一次,其余情况都会走onNewIntent,并且会清空主界面上面的其他页面。 singleInstance 模式 在一个新栈中创建该Activity的实例,并让多个应用共享该栈中的该Activity实例。一旦该模式的Activity实例已经存在于某个栈中,任何应用再激活该Activity时都会重用该栈中的实例( 会调用实例的 onNewIntent() )

singleTask and singleInstance not respected when using PendingIntent?

淺唱寂寞╮ 提交于 2020-01-02 06:38:08
问题 I have an activity with launchMode set to singleTask: <activity android:name="com.blah.blah.MyActivity" android:launchMode="singleTask"> </activity> I have an ongoing notification with a PendingIntent that launches that activity: Intent activityIntent = new Intent( this, MyActivity.class ); TaskStackBuilder stackBuilder = TaskStackBuilder.create( this ); stackBuilder.addParentStack( MyActivity.class ); stackBuilder.addNextIntent( activityIntent ); PendingIntent resultingActivityPendingIntent

Set activity launch mode programmatically

痴心易碎 提交于 2019-12-23 10:19:38
问题 I need to call activity with different launchMode according to my app state. In one case it should be singleInstance , in other - singleTask . I know how to set launchMode in AndroidManifest , but since it should be dynamic property I have to do it from code. I thought, that I can add some specific flag to intent, before starting activity, but I found only singleTop flag. So is any way to solve this issue? Thanks 回答1: After some investigations I've noticed that it is impossible to do that in

SINGLE_TOP | CLEAR_TOP seem to work 95% of the time. Why the 5%?

拈花ヽ惹草 提交于 2019-12-22 01:56:49
问题 I have a nearly-finished application with a non-trivial activity structure. There are push notifications associated with this app, and selecting the notification entry is supposed to bring up a specific activity regardless of whether the app is foreground/background/not active. If the app is not active, I have been able to successfully start the app and auto-navigate to the appropriate part. However, when the app is active, I have a problem. I will present a simplified version of the issue,

Single Instance : Launch Mode of Launcher Activity

狂风中的少年 提交于 2019-12-18 18:05:31
问题 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.jatin.notification"> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:launchMode="singleInstance" > <!-- Activity A -->

How should I define launchMode in AndroidManifest.xml - Using PhoneGap & JQM

三世轮回 提交于 2019-12-18 11:48:44
问题 I am struggling to restrict my application to a single instance. Currently if the user presses home screen to quit the application, then does something outside and clicks on the application's icon again, it launches the App's second instance. Here is my complete manifest file: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mydomain.qfa" android:versionCode="4" android:versionName="1.3"> <uses-sdk android:minSdkVersion=

LaunchMode & Recent App Principle

。_饼干妹妹 提交于 2019-12-11 13:06:08
问题 I have a WidgetResultActivity and a NotificationResultActivity, I set both their launchmode=singleInstance. But they have different behaviors: WidgetResultActivity will not opened from RECENT, while NotificationResultActivity will always be opened from RECENT(It is opened alone! Without MainActivity). So How can I forbid NotificationResultActivity opening from REcent, thx. <activity android:name=".WidgetResultActivity" android:launchMode="singleInstance" android:theme="@android:style/Theme

Activity marked as “SingleTask” brought forward

情到浓时终转凉″ 提交于 2019-12-11 02:52:58
问题 I am trying to wrap my head around the different options of Android's Activity launch mode (See documentation: Tasks and Back Stack According to the documentation, when launching an activity that is marked as "singleTask": "... Instead, either a new task starts for the Browser or, if the Browser already has a task running in the background, that task is brought forward to handle the new intent." According to the way singleTask is described, either a new task is created, or, if the activity

Getting java.lang.RuntimeException while starting an activity

前提是你 提交于 2019-12-10 18:14:24
问题 I have an activity, A , which is SingleTop when I want to start this activity inside her, with another intent data, like this: Intent intent = new Intent(); intent.setData(Uri.parse("something://someone")); startActivity(intent); this exception occurs: startActivityUncheckedLocked: task left null V/ActivityManager( 596): java.lang.RuntimeException: here V/ActivityManager( 596): at com.android.server.am.ActivityStackSupervisor.startActivityUncheckedLocked(ActivityStackSupervisor.java:1646) V

Android activity launch mode and deeplink issue

心不动则不痛 提交于 2019-12-07 06:28:40
问题 My app has 2 activities. The root activity of the app is the MainActivity. If credentials are missing or invalid the user will be redirected to the LoginActivity while finishing the MainActivity. If i set the launch mode of the main activity to singleTask and I am in an inner fragment of the LoginActivity => minimize the app -> launch the app from the launcher icon => The MainActivity launches (since it is a singleTask activity) and redirects to the LoginActivity but of course to the first