30

実際に送信される前に送信SMSを傍受し、その内容を取得してから、いくつかの基準に従って無視/送信することは可能ですか?

例えば。すべての国際的なテキスト (先頭に 00 が付いた数字) をブロックしますが、それ以外はすべて許可します。

4

5 に答える 5

19

着信 SMS

ブロードキャスト レシーバーを使用して、SMS リスナーを介して着信 SMS を傍受できます。着信 SMS を変更したり、受信ボックスに到達しないように破棄したりできます。

送信 SMS

content observer送信するSMSを聞くことはできcontent://sms/outますが、ネイティブのSMSアプリで変更することはできません。明らかに内容を変更することはできますがcontent://sms/out、意味がありません.

于 2011-10-17T07:48:34.520 に答える
8

私が見つけたものに基づいて、答えは「不可能」または「可能かもしれない」のいずれかのようですが、テキストを受信できるように、独自の SMS アプリを作成する必要がありますSMS になる前に、API を呼び出して実際に送信するキューに入れる前に、必要なチェックを実行できます。

ごめんなさい=(

于 2011-10-13T05:01:40.020 に答える
7

私の知る限り、送信 SMS メッセージをスパイすることはできますが、送信を停止することはできません。

送信 SMS メッセージを検出する方法は次のとおりです。 Android で送信 SMS または送信ボックスを聞く

しかし、これは基本的にデータベースから読み取ることによって行われるため、SMS の送信を停止できるとは思えません。

がんばって。

エマニュエル

于 2011-10-12T18:27:57.067 に答える
5

これは、私が OutgoingSMSReceiver を作るために行ったことです。

public final class OutgoingSMSReceiver extends Service {


    private static final String CONTENT_SMS = "content://sms/";
    private CallerHistoryDataSource  database =  new  CallerHistoryDataSource(UCDGlobalContextProvider.getContext());
    static String messageId="";


    private class MyContentObserver extends ContentObserver {



        public MyContentObserver() {
            super(null);
        }

        @Override
        public void onChange(boolean selfChange) {
            super.onChange(selfChange);


            Uri uriSMSURI = Uri.parse(CONTENT_SMS);
            Cursor cur = UCDGlobalContextProvider.getContext().getContentResolver().query(uriSMSURI, null, null, null, null);
             // this will make it point to the first record, which is the last SMS sent
            cur.moveToNext();

            String message_id = cur.getString(cur.getColumnIndex("_id"));
            String type = cur.getString(cur.getColumnIndex("type"));

            if(type.equals(Constants.SMS_TYPE_OUTGOING)){

                /**
                 *  onChange is fired multiple times for a single SMS, this is to prevent multiple entries in db.
                 * 
                 */
                if(!message_id.equals(messageId))
                {
                    String content = cur.getString(cur.getColumnIndex("body"));
                    String msisdnWithCountryCodeOrPrefix = cur.getString(cur.getColumnIndex("address"));
                    String msisdn = MSISDNPreFixHandler.fixMsisdn(msisdnWithCountryCodeOrPrefix);

                    Sms sms = new Sms();
                    sms.setType(Constants.SMS_TYPE_OUTGOING);
                    sms.setMsisdn(msisdn);
                    sms.setContent(content);



        Log.i("MyContentObserver", "Sent SMS saved: "+content);                                     

                }
                messageId = message_id;

            }

    }


        @Override
        public boolean deliverSelfNotifications() {
            return false;
        }
    }




    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        MyContentObserver contentObserver = new MyContentObserver();
        ContentResolver contentResolver = getBaseContext().getContentResolver();
        contentResolver.registerContentObserver(Uri.parse(CONTENT_SMS),true, contentObserver);
        //Log.v("Caller History: Service Started.", "OutgoingSMSReceiverService");
    }

    @Override
    public void onDestroy() {
        //Log.v("Caller History: Service Stopped.", "OutgoingSMSReceiverService");    
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        //Log.v("Caller History: Service Started.", "OutgoingSMSReceiverService");
        /**
         *   Constant to return from onStartCommand(Intent, int, int): if this service's process is killed while it is started 
         *   (after returning from onStartCommand(Intent, int, int)), then leave it in the started state but don't retain this delivered intent. 
         *   Later the system will try to re-create the service. Because it is in the started state, it will guarantee to call 
         *   onStartCommand(Intent, int, int) after creating the new service instance; if there are not any pending start commands to be 
         *   delivered to the service, it will be called with a null intent object, so you must take care to check for this.
         *   This mode makes sense for things that will be explicitly started and stopped to run for arbitrary periods of time, such as a 
         *   service performing background music playback.
         */
        return START_STICKY;

    }

    @Override
    public void onStart(Intent intent, int startid) {
        Log.v("Caller History: Service Started.", "OutgoingSMSReceiverService");
    }
}
于 2012-11-14T07:36:20.527 に答える