Last active
December 17, 2015 12:49
-
-
Save XavierTalpe/5612793 to your computer and use it in GitHub Desktop.
Intercepting broadcasts to other applications in Android.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | |
| <uses-permission android:name="android.permission.RECEIVE_SMS" /> | |
| <application> | |
| <receiver android:name=".SmsReceivedBroadcastReceiver"> | |
| <!-- A high priority makes sure our BroadCastReceiver is called first. --> | |
| <intent-filter android:priority="999"> | |
| <action android:name="android.provider.Telephony.SMS_RECEIVED" /> | |
| </intent-filter> | |
| </receiver> | |
| </application> | |
| </manifest> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public final class SmsReceivedBroadcastReceiver extends BroadcastReceiver { | |
| @Override | |
| public void onReceive( Context aContext, Intent aIntent ) { | |
| // Process event. | |
| Toast.makeText( aContext, "Received SMS", Toast.LENGTH_LONG ); | |
| // Prevent others from receiving broadcast. | |
| abortBroadcast(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment