This link answers the question about best practice. It is technically allowed and the "enforcement" is that annoyed users are likely to uninstall such apps.
http://developer.android.com/guide/practices/design/seamlessness.html#interrupt Does anybody understand the purpose for requiring the DEFAULT category for the Intent filter to match? android.intent.category.DEFAULT On Nov 10, 12:22 pm, jotobjects <[email protected]> wrote: > I did a little experimenting. It is possible to start and activity > from a service and the activity does interrupt the user and hide the > previous activity. > > I would guess this is not "best practice"? > > Also I don't understand the purpose of the required DEFAULT category > here. > > Anyone understand this? > > The following code starts an activity in another application from > inside a service. > > Intent intent = new Intent(Intent.ACTION_VIEW); > intent.addCategory("test.foobar.123"); > intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); > startActivity(intent); > > Where the activity to start has this in the manifest - > > <intent-filter> > <action android:name="android.intent.action.MAIN" /> > <category android:name="android.intent.category.SAMPLE_CODE" /> > </intent-filter> > <intent-filter> > <action android:name="android.intent.action.VIEW" /> > <category android:name="test.foobar.123" /> > <category android:name="android.intent.category.DEFAULT" /> > </intent-filter> > > Without android.intent.category.DEFAULT I got this - > > W/IntentResolver( 569): resolveIntent failed: found match, but none > with Intent.CATEGORY_DEFAULT > I/ActivityManager( 569): Starting activity: Intent > { action=android.intent.action.VIEW categories={test.foobar.123} > flags=0x10000000 } > W/dalvikvm( 898): threadid=17: thread exiting with uncaught exception > (group=0x4000fe70) > E/AndroidRuntime( 898): Uncaught handler: thread Thread-9 exiting due > to uncaught exception > E/AndroidRuntime( 898): android.content.ActivityNotFoundException: > > On Nov 9, 11:08 am, jotobjects <[email protected]> wrote: > > > Why do you need a result? There is a tartActivity(intent) method you > > can use. > > > What does it mean to start an activity from a process that is not > > visible as in this case? Does it interrupt the user and is that > > desirable and/or allowed? > > > On Nov 9, 7:41 am, michael <[email protected]> wrote: > > > > Hello, > > > > Anyone could give me suggestion??? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

