android - How force aplication always run in its own task? -
android - How force aplication always run in its own task? -
i think app manager runs application after installation in wrong way. runs applications in task. when press home , press application icon runs sec task application.
i tested it. made 2 applications app1, app2. app2 has 2 activities , b. app1 runs app2 in simplest way.
intent intent = new intent(intent.action_run); intent.setcomponent(new componentname("org.app2.test", "org.app2.test.screen1"));
test 1. run app1. app1 runs app2 activity a. acctivity runs activity b. press home. press app2 icon. can see app2 activity a. (wrong. have tasks app2)
that changed code launching app2.
intent intent = new intent(intent.action_main, null); intent.addcategory(intent.category_launcher); intent.addflags(intent.flag_activity_new_task); intent.setcomponent(new componentname("org.app2.test", "org.app2.test.screen1"));
test 2. run app1. app1 runs app2 activity a. acctivity runs activity b. press home. press app2 icon. can see app2 activity b. (ok.)
how can alter app2 manifest , forcefulness app2 run in own task?
<application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".screen1" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".screen2"> <intent-filter> <action android:name="org.app2.test.screen2" /> <category android:name="android.intent.category.default"></category> </intent-filter> </activity> </application>
i detects situation of first run of application , restarts it.
if (first_run) { log.w(tag, apphelper.first_run); pendingintent intent = pendingintent.getactivity(this.getbasecontext(), 0, (new intent(getintent())).addcategory(intent.category_launcher), intent.flag_activity_new_task); alarmmanager mgr = (alarmmanager)this.getsystemservice(context.alarm_service); mgr.set(alarmmanager.rtc, system.currenttimemillis() + 1000, intent); system.runfinalizersonexit(true); system.exit(2); return; }
android android-manifest
Comments
Post a Comment