Skip to content

Instantly share code, notes, and snippets.

@drmercer
Last active October 27, 2015 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drmercer/67302c7ccd2b4454fb07 to your computer and use it in GitHub Desktop.
Save drmercer/67302c7ccd2b4454fb07 to your computer and use it in GitHub Desktop.
An intent filter that only accepts intents from a certain application package. (For Android development)
<!-- This is a mock AndroidManifest.xml file, to show you the general context of this intent filter -->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.danmercer.ponderizer" >
<application ... >
...
<!-- Accept text via ACTION_SEND only from the Github Android app ("com.github.mobile") -->
<activity
android:name=".MyShareTextActivity"
android:label="Add text to MyApp" >
<intent-filter android:label="Share to MyApp">
<action android:name="android.intent.action.SEND" />
<category android:name="com.github.mobile" />
<!-- This ^ makes it only accept intents from package "com.github.mobile" -->
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
...
</application>
</manifest>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment