使用android.provider.Telephony中的SECRET_CODE

我想实现一个基本的想法,在android中制作资产负债表.如果我在我的号码拨号屏幕上写*#*#1234#*#*,那么它必须在我的应用程序中增加34(或者可能在文本文件中).为了实现这个想法,我遇到了android.provider.Telephony.SECRET_CODE.

我想要的是从手机的拨号盘读取任何数字,如*#*#< number>#*#*.因此,我希望我的代码以某种方式运行,以便将此格式的任何代码标识为密码:*#*#12 $$#*#*.我想很难想象它是否有任何可行的方法,但如果有人知道的话,我会非常好奇地知道.非常感谢提前!

解决方法:

http://blog.udinic.com/2013/05/17/create-a-secret-doorway-to-your-app

检查此链接.

这是一段代码示例.在您的清单中,声明您的接收器并使用密码,例如:111222

<receiver android:name=".receiver.DiagnoserReceiver">
    <intent-filter>
        <action android:name="android.provider.Telephony.SECRET_CODE"/>
        <data android:scheme="android_secret_code" android:host="111222"/>
    </intent-filter>
</receiver>

然后创建接收器:

public class DiagnoserReceiver extends broadcastReceiver {

    public void onReceive(Context context, Intent intent) {
        if ("android.provider.Telephony.SECRET_CODE".equals(intent.getAction())) {
            //Do your increment here
        }
    }
}

我想如果你想要多个数字,你可以添加你的应用会监听的代码变体:

<intent-filter>
    <action android:name="android.provider.Telephony.SECRET_CODE"/>
    <data android:scheme="android_secret_code" android:host="111222"/>
    <data android:scheme="android_secret_code" android:host="1234"/>
    <data android:scheme="android_secret_code" android:host="1235"/>
    <data android:scheme="android_secret_code" android:host="1236"/>
    <data android:scheme="android_secret_code" android:host="1237"/>
</intent-filter>

编辑:

你可以试试这个SO post I found

only to match the beginning of host. The rules are these:

  • Put * as the first character of the host.
  • Write the rest of of the host until the end.
android:host="*site.com"
android:pathPattern=".*"
android:scheme="http" />

It will catch links of:

  • www.site.com
  • site.com
  • mail.site.com

所以你应该能够通配符的字体

<data android:scheme="android_secret_code" android:pathPattern="*" android:host="*34"/>

理论上它应该适用于0034 … 9934

**小心:**

任何人都可以反编译您的应用并查看清单文件中的代码.所以无论你做什么,都要确保它是安全的. IE浏览器.如果您从接收方打开活动,请确保活动首先要求输入密码.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...