Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't block outgoing text messages.</p> <p>Here's what I use for blocking incoming texts.</p> <hr> <p>SmsReceiver.java</p> <pre><code>import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.SmsMessage; import android.widget.Toast; public class BroadCastReceiver extends BroadcastReceiver { /** Called when the activity is first created. */ private static final String ACTION = "android.provider.Telephony.SEND_SMS"; public static int MSG_TPE=0; public void onReceive(Context context, Intent intent) { String MSG_TYPE=intent.getAction(); if(MSG_TYPE.equals("android.provider.Telephony.SMS_RECEIVED")) { // Toast toast = Toast.makeText(context,"SMS Received: "+MSG_TYPE , Toast.LENGTH_LONG); // toast.show(); Bundle bundle = intent.getExtras(); Object messages[] = (Object[]) bundle.get("pdus"); SmsMessage smsMessage[] = new SmsMessage[messages.length]; for (int n = 0; n &lt; messages.length; n++) { smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]); } // show first message Toast toast = Toast.makeText(context,"BLOCKED Received SMS: " + smsMessage[0].getMessageBody(), Toast.LENGTH_LONG); toast.show(); abortBroadcast(); for(int i=0;i&lt;8;i++) { System.out.println("Blocking SMS **********************"); } } else if(MSG_TYPE.equals("android.provider.Telephony.SEND_SMS")) { Toast toast = Toast.makeText(context,"SMS SENT: "+MSG_TYPE , Toast.LENGTH_LONG); toast.show(); abortBroadcast(); for(int i=0;i&lt;8;i++) { System.out.println("Blocking SMS **********************"); } } else { Toast toast = Toast.makeText(context,"SIN ELSE: "+MSG_TYPE , Toast.LENGTH_LONG); toast.show(); abortBroadcast(); for(int i=0;i&lt;8;i++) { System.out.println("Blocking SMS **********************"); } } } } </code></pre> <hr> <p>AndroidManifest.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="APP.PACKAGE.NAMEHERE" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="10" /&gt; &lt;supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:resizeable="true" android:anyDensity="true" /&gt; &lt;uses-feature android:name="android.hardware.telephony" /&gt; &lt;uses-permission android:name="android.permission.READ_SMS" /&gt; &lt;uses-permission android:name="android.permission.WRITE_SMS" /&gt; &lt;uses-permission android:name="android.permission.SEND_SMS" /&gt; &lt;uses-permission android:name="android.permission.RECEIVE_SMS" /&gt; &lt;uses-permission android:name="android.permission.RECEIVE_MMS" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" &gt; &lt;activity android:name=".APPACTIVITYHERE" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden" &gt; &lt;service android:name=".MyService" android:enabled="true"/&gt; &lt;receiver android:name="SmsReceiver"&gt; &lt;intent-filter android:priority="2147483647"&gt; &lt;action android:name="android.provider.Telephony.SMS_SENT"/&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;service android:name=".MyServiceSentReceived" android:enabled="true"/&gt; &lt;receiver android:name="SmsReceiver"&gt; &lt;intent-filter android:priority="2147483645"&gt; &lt;action android:name="android.provider.Telephony.SMS_RECEIVED"/&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;/application&gt; </code></pre> <p></p> <p>The main thing to take away from the manifest is the service block, receiver block, and the permissions.</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      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