简体   繁体   中英

Intercepting SMS Intents (non-default application)

I'm thinking about writing up an little app for Android that intercepts received texts and pushes them to a Windows computer, where you can respond to it. However, I know that you cannot send text messages on Android without being the default SMS app, and I don't want to make an entire texting client.. Just something that intercepts the text and displays it on Windows, but uses the default SMS app for sending and receiving. Is this possible?

So to receive a SMS first you have to set an IntentFilter with highest priority. Like:

IntentFilter filter = new IntentFilter("android.provider.Telephony.SMS_RECEIVED");
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
registerReceiver(smsReceiver , filter);

Where smsReceiver is a class that extends BroadcastReceiver. Inside the onReceive method you can call abortBroadcast(); which will stop the broadcasting of the "android.provider.Telephony.SMS_RECEIVED" event. More info http://developer.android.com/reference/android/content/BroadcastReceiver.html .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM