Hi all, I made an Activity that I'd like to let others call by passing me a url. I expect a url like this:
http://www.mysite.com/input/user-supplied-data and my activity intent filter looks like this: <intent-filter> <action android:name="android.intent.action.VIEW"></action> <category android:name="android.intent.category.DEFAULT"></ category> <category android:name="android.intent.category.BROWSABLE"></ category> <data android:host="www.mysite.com" android:pathPrefix="/input/" android:scheme="http"></data> </intent-filter> This works well, users can invoke my activity like this: Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.mysite.com/input/" + "orange")); startActivity(intent); and android will pop up a chooser dialog asking if I want to open the data in either the native browser, or my app. Some third party developers that want to use my activity might not want the intermediate step of showing the chooser dialog though - they know they want to use my activity, and only my activity, and send the user there directly from their app. I added a unique category string to my intent filter like this, so that third party developers can reference it: <category android:name="com.me.test.intent.category.VIEWTEST" /> so now a third party developer can do this: Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.mysite.com/input/" + "orange")); intent.addCategory("com.me.test.intent.category.VIEWTEST"); startActivity(intent); and since my app should be the only one declaring that category in an intent filter, android will just move the user to it directly. Is this a good practice, or is there some better way to allow third party developers to call my activity 'directly'? This does seem to work, I just don't know if this practice of using a custom category is frowned upon. In the end, my intent filter looks like this: <intent-filter> <action android:name="android.intent.action.VIEW"></action> <category android:name="com.me.test.intent.category.VIEWTEST" /> <category android:name="android.intent.category.DEFAULT"></ category> <category android:name="android.intent.category.BROWSABLE"></ category> <data android:host="www.mysite.com" android:pathPrefix="/input/" android:scheme="http"></data> </intent-filter> Thanks -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en