Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Block Incoming SMS in kitkat 4.4

I am developing an android application that will block incoming sms from specific numbers i have successfully achieved this. The app is working fine in other versions except the version 4.4.4. I have set its periority but nothing worked for me. here is the code for receiver in manifest

<receiver android:name=".msgreceiver"><intent-filter android:priority="1000"><action android:name="android.provider.Telephony.SMS_RECEIVED"/></intent-filter></receiver>

and i am blocking the sms by calling this method in java

this.abortBroadcast();

I search to solve this problem and found that in kitkat the app need to set as default messaging app to abort the msg. But i want to do this programatically. Is there any way to block incoming sms in kitkat programatically???

like image 446
Mehtab Ahmed Avatar asked Oct 30 '22 18:10

Mehtab Ahmed


1 Answers

I search to solve this problem and found that in kitkat the app need to set as default messaging app to abort the msg

That is the case for API Level 19 and higher. At the moment, that is ~60% of Android devices actively using the Play Store.

But i want to do this programatically

You are welcome to ask the user to make your app be the default SMS client, via an ACTION_CHANGE_DEFAULT Intent. You cannot force your app to be the default SMS client through the Android SDK, outside of some security flaw.

Is there any way to block incoming sms in kitkat programatically?

Write a full SMS client that has SMS-blocking capabilities.

like image 109
CommonsWare Avatar answered Nov 15 '22 06:11

CommonsWare