Intercept incoming SMS samsung - Android -
i'm intercepting sms using following code in java
public class smsreceiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { bundle extras = intent.getextras(); if (extras == null) return; object[] pdus = (object[]) extras.get("pdus"); (int = 0; < pdus.length; i++) { smsmessage smessage = smsmessage.createfrompdu((byte[]) pdus[i]); string sender = smessage.getoriginatingaddress(); string body = smessage.getmessagebody().tostring(); log.i("tag", body); //... whatever message here } } }
with following receiver in manifest.xml
</receiver> <receiver android:name="com.example.test.smsreceiver" > <intent-filter> <action android:name="android.provider.telephony.sms_received" /> </intent-filter> </receiver>
it's working fine nexus 5, it's not in samsung, knows how make work in samsung
pre-kitkat sms broadcasts intercepted or aborted, hangouts still process message. see post:
suppress / block broadcastreceiver in app
and this:
enabling sms support in hangouts 2.0 breaks broadcastreceiver of sms_received in app
hangouts has registered abortsmsrecevier priority "3" setting receiver priority above "3" should solve problem , intercept it. however, if trying message "first" "999" should that. however, aware not ideal since anti-spam apps, example, may need process message before apps does, depending on app does. (this problem - apps "fighting highest priority" reason android changed kitkat, better or worse...)
this excerpt google talk / babel manifest:
<receiver android:name="com.google.android.apps.babel.sms.abortsmsreceiver" android:permission="android.permission.broadcast_sms" android:enabled="false"> <intent-filter android:priority="3"> <action android:name="android.provider.telephony.sms_received" /> </intent-filter> </receiver>
if trying abort message, have problems. hangouts sms receiver processes message set integer.max_value
, receiver aborts message 1 posted.
here other receiver:
<receiver android:name="com.google.android.apps.babel.sms.smsreceiver" android:permission="android.permission.broadcast_sms" android:enabled="false"> <intent-filter android:priority="2147483647"> <action android:name="android.provider.telephony.sms_received" /> </intent-filter> </receiver>
note: priorities on "999" or below "-999" "system level" - however, documentation states non-system apps requesting priority above have "unpredictable" behavior. i've seen - apps not predictably or reliable "beat" other apps above level (depending on device, install order, rebooting, etc.).
Comments
Post a Comment