Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can send msg programmatically </p> <pre><code>SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNo, null, sms, null, null); Toast.makeText(getApplicationContext(), "SMS Sent!",Toast.LENGTH_LONG).show(); </code></pre> <p>For Sms Receiver</p> <p>public class SmsReceiver extends BroadcastReceiver {</p> <pre><code>public static final String SMS_EXTRA_NAME = "pdus"; public static final String SMS_URI = "content://sms"; public void onReceive( Context context, Intent intent ) { // Get SMS map from Intent Bundle extras = intent.getExtras(); if ( extras != null ) { // Get received SMS array Object[] smsExtra = (Object[]) extras.get( SMS_EXTRA_NAME ); for ( int i = 0; i &lt; smsExtra.length; ++i ) { SmsMessage sms = SmsMessage.createFromPdu((byte[])smsExtra[i]); if(IsBlackListNumber(context,sms)){ this.abortBroadcast(); // Toast.makeText( context, "BlackList", Toast.LENGTH_SHORT ).show(); } else{ //Toast.makeText( context, "No BlackList", Toast.LENGTH_SHORT ).show(); } } } // WARNING!!! // If you uncomment next line then received SMS will not be put to incoming. // Be careful! // this.abortBroadcast(); } private boolean IsBlackListNumber(Context context, SmsMessage sms){ boolean isExist = false; ContactInfoDataSource datasource = new ContactInfoDataSource(context); datasource.read(); if(datasource.IsBlackListNumber(sms.getOriginatingAddress())){ SmsInfoEnt smsInfoEnt = new SmsInfoEnt(); smsInfoEnt.setMessage(sms.getMessageBody()); smsInfoEnt.setName(datasource.GetName(sms.getOriginatingAddress())); smsInfoEnt.setPhoneNo(sms.getOriginatingAddress()); SmsInfoDataSource Smsdatasource = new SmsInfoDataSource(context); Smsdatasource.open(); Smsdatasource.AddBlockSMS(smsInfoEnt); Smsdatasource.close(); isExist = true; } datasource.close(); return isExist; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload