Mtk Android 暗码格式定制功能

1.AndroidManifest.xml 添加暗码,并添加注册receiver:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mediatek.engineermode"
    android:sharedUserId="android.uid.phone"
    android:versionCode="1"
    android:versionName="1.0" >
    <application android:label="@string/app_name" 
	android:theme="@android:style/Theme.Holo">

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

    </application>

</manifest>

2.添加文件VersionCheckReceiver.java,代码如下:

package com.mediatek.engineermode;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
import android.util.Log;

public class VersionCheckReceiver extends BroadcastReceiver{
    private static final String TAG = "VersionCheckReceiver";
	
    @Override
    public void onReceive(Context context, Intent intent) {
        VersionCheck(context);
    }

    private void VersionCheck(Context context) {
    	Toast.makeText(context, "Surplus Baseline Code", Toast.LENGTH_SHORT).show();
    }
}

3.暗码格式定制 参照文件:SpecialCharSequenceMgr.java

    /**
     * Handles secret codes to launch arbitrary activities in the form of *#*#<code>#*#*.
     * If a secret code is encountered an Intent is started with the android_secret_code://<code>
     * URI.
     *
     * @param context the context to use
     * @param input the text to check for a secret code in
     * @return true if a secret code was encountered
     */
    static private boolean handleSecretCode(Context context, String input) {
        // Secret codes are in the form *#*#<code>#*#*
        int len = input.length();
        if (len > 8 && input.startsWith("*#*#") && input.endsWith("#*#*")) {
            Intent intent = new Intent(TelephonyIntents.SECRET_CODE_ACTION,
                    Uri.parse("android_secret_code://" + input.substring(4, len - 4)));
            context.sendBroadcast(intent);
            return true;
        }

        return false;
    }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

架构师训练营

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值