English 中文(简体)
停止在甲型六氯环己烷中分离的SMS/MMS
原标题:Blocking outgoing SMS/MMS in android
  • 时间:2011-11-16 02:15:01
  •  标签:
  • android

我阅读了SMS的内容,并在进入盒子之前加以封杀。 该守则如下:

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 < 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<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<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<8;i++)
            {
                System.out.println("Blocking SMS **********************");
            }

        }

    }

}

The code works fine on Incoming SMS. Shows the Sms pdu on Toast and blocks the SMS to enter in to Inbox. But my problem is that same Code is not working for Outgoing SMS. It doesnt blocks the Outgoing SMS. I have registered BroadcastReceiver in the AndroidManifest as follows.

<service  android:name=".MyService"    android:enabled="true"/>
         <receiver android:name="BroadCastReceiver">
                <intent-filter  android:priority="2147483647">
                    <action   android:name="android.provider.Telephony.SMS_SENT"/>
                </intent-filter>
         </receiver>
    <service  android:name=".MyServiceSentReceived"    android:enabled="true"/>
             <receiver android:name="BroadCastReceiver">
                    <intent-filter  android:priority="2147483645">
                        <action   android:name="android.provider.Telephony.SMS_RECEIVED"/>
                    </intent-filter>
             </receiver>
            <intent-filter>
                <action android:name="android.intent.action.SENDTO"></action>
                <data android:scheme="smsto"></data>
                <category android:name="android.intent.category.DEFAULT"></category>
            </intent-filter>

    and Permissions Like:
    <uses-permission android:name="android.permission.RECEIVE_SMS" />  
         <uses-permission android:name="android.permission.READ_SMS"/>
         <uses-permission android:name="android.permission.SEND_SMS"/>

任何人都可以帮助我 什么是错的,为什么我无法阻止即将离任的SMS。 增 编

问题回答

只有在以下行动时才援引你的接收器:android.provider. Telephony.SMS_RECEIVED。 因此,当SMS被送去时,它没有反应。

我远非专家,但我认为,不可能阻止即将发出的信息。 缺席的SMS 应用程序使用android.telephony.SmsManager s methodsSendDataMessage(,该代码发送任何广播。

我在寄出时就抓住了这次活动,即利用观察员进行“连续的烟://”的问答,然后拿到最后一批烟ms,然后删除。

我的问题是,这一想法完全针对的是支持者,而不是真正的手段。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签