zoukankan      html  css  js  c++  java
  • 安卓短信过滤器小程序

    对于安卓的短信广播接受者支持,谷歌应该在安卓4.2以后就開始弱化了,也就是配置起来较麻烦唯一。可是到了5.0的时候就应该全然不支持了。由于谷歌觉得这样的技术对用户个人隐私造成非常大影响。其实也正是如此。黑客能够非常easy的获取到用户的短信。


    以下写一个短信过滤的小demo。

    /*
    *创建一个短信接收器。继承广播接受者
    */
    public class SmsReceiver extends BroadcastReceiver {
    
        @Override
        public void onReceive(Context context, Intent intent) {
            System.out.println("短信到来了。 。。。");
            Object[] objs = (Object[]) intent.getExtras().get("pdus");
            for (Object obj : objs) {
                // 得到短信对象
                SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) obj);
                String body = smsMessage.getMessageBody();
                String sender = smsMessage.getOriginatingAddress();
                System.out.println("body:" + body);
                System.out.println("sender:" + sender);
                // 终止掉当前的广播。

    if ("5556".equals(sender)) { abortBroadcast(); } } } }

    须要在在AndroidManifest.xml配置相应的权限:

    <?

    xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.itheima.smsreceiver" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <uses-permission android:name="android.permission.RECEIVE_SMS"/> <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.itheima.smsreceiver.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <receiver android:name="com.itheima.smsreceiver.SmsReceiver"> <intent-filter android:priority="1000"> <action android:name="android.provider.Telephony.SMS_RECEIVED"/> </intent-filter> </receiver> <!-- 配置广播接受者 --> <receiver android:name="com.itheima.smsreceiver.OutCallReceiver"> <intent-filter android:priority="1000"> <!-- 配置广播接收者关心的事件是外拨电话 --> <action android:name="android.intent.action.NEW_OUTGOING_CALL"/> </intent-filter> </receiver> </application> </manifest>

    然后模拟给手机发短信,就能拦截短信了。

    模拟发送短信

    Log信息:
    截取的log,拦截到了信息

  • 相关阅读:
    javascript星级评分
    JavaScript input框输入实时校验
    ios 软键盘顶起这个页面
    JavaScript 属性操作
    ios隐藏软键盘
    SVN-Attempted to lock an already-locked dir错误
    javascript 判断是否使用的是ipad
    session不一定非得要cookie开启才能使用。也可以使用get传递参数
    [Linux]非外网环境下配置lnmp心得
    session和cookie的总结
  • 原文地址:https://www.cnblogs.com/yfceshi/p/7265137.html
Copyright © 2011-2022 走看看