i'm working on a little project which receive and show Message only by specific number,and don't show in inbox, is there is any method to prevent or cancel the default sms app?thanks in advance i'm attaching my code of Broadcasting and Manifest
public class reciever extends BroadcastReceiver {
public String senderNumer=null;
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle=intent.getExtras();
if (bundle!=null)
{
Object[] pdus= (Object[]) bundle.get("pdus");
// String senderNumer=null;
for (int i=0;i<pdus.length; i++)
{
SmsMessage sms=SmsMessage.createFromPdu((byte[]) pdus[i]);
senderNumer=sms.getOriginatingAddress();
String message=sms.getDisplayMessageBody();
}
if (senderNumer.equals("+92*******") || senderNumer.equals("03*******"))
{
Toast.makeText(context,senderNumer+ "Message Recieved By Special Num",Toast.LENGTH_SHORT ).show();
Intent actionIntent = new Intent(context, MainActivity.class);
actionIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
actionIntent.putExtra("msg", senderNumer);
context.startActivity(actionIntent);
abortBroadcast();
}
}
Manifest file
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".reciever" class=".reciever">
<intent-filter android:priority="100000000" >
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
</application>