android - Filter Intent based on custom data -


i want broadcast intent custom-data , receiver have custom data should receive intent, how done ?

this how broadcast intent :

intent intent = new intent();  intent.setaction("com.example");  context.sendbroadcast(intent); 

and define broadcast receiver following :

 <receiver android:name="com.test.myreceiver" android:enabled="true">         <intent-filter>             <action android:name="com.example"></action>         </intent-filter>     </receiver> 

setup myreceiver class how anmustangs posted.

public class myreceiver extends broadcastreceiver{      @override     public void onreceive(context arg0, intent intent) {         //do     } } 

you shouldn't have check intent action because you've filtered based on you've included in manifest, @ least in simple case. have other actions , filters in case you'd need have kind of check on received intent.

if want filter filter on data, sdk documentation on intent filters covers that. i'm not great data types example give relatively poor. in event, here link manifest intent filter page: http://developer.android.com/guide/topics/manifest/intent-filter-element.html

and specific page data element; http://developer.android.com/guide/topics/manifest/data-element.html


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -