Intent-Filter is the way to go!
In your AndroidManifest.xml you have to tell Android that your app can respond to such an Intent.
Example:
<application ... >
<activity ... >
<intent-filter>
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
</intent-filter>
</activity>
</application>
Than your Activity can access the Intents data when called.
Example:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// get intent-data
Intent intent = getIntent();
if (Intent.ACTION_SENDTO.equals(intent.getAction())) {
Toast.makeText(this, intent.getDataString(), Toast.LENGTH_LONG).show();
}
// close activity
finish();
}
With this code you can choose your App as the receiver whenever another App (e.g. Contacts) fires such an Intent.
Example to fire such an Intent (Screenshot from Contacts):
