1, Contact:SpecialCharSequenceMgr.java
static 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("android.provider.Telephony.SECRET_CODE",
Uri.parse("android_secret_code://" + input.substring(4, len - 4)));
context.sendBroadcast(intent);
return true;
}
中间sendBroadcast
2,Setting的packageAndroidManifest.xml
<receiver android:name=".secret">
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data android:scheme="android_secret_code" android:host="1234"/>
</intent-filter>
</receiver>
3,在Action的类里面
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
String host = intent.getData() != null ? intent.getData().getHost() : null;
if (intent.getAction().equals(SECRET_CODE_ACTION)) {
Intent i = new Intent(Intent.ACTION_MAIN);
if ("1111".equals(host)) {
i.setClass(context, EngineerMode.class);
Log.i(TAG,"hello 1111..........");
}
else {
// i.setClass(context, TestingSettings.class);
}
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
这就启动了新的apk
static 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("android.provider.Telephony.SECRET_CODE",
Uri.parse("android_secret_code://" + input.substring(4, len - 4)));
context.sendBroadcast(intent);
return true;
}
中间sendBroadcast
2,Setting的packageAndroidManifest.xml
<receiver android:name=".secret">
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data android:scheme="android_secret_code" android:host="1234"/>
</intent-filter>
</receiver>
3,在Action的类里面
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
String host = intent.getData() != null ? intent.getData().getHost() : null;
if (intent.getAction().equals(SECRET_CODE_ACTION)) {
Intent i = new Intent(Intent.ACTION_MAIN);
if ("1111".equals(host)) {
i.setClass(context, EngineerMode.class);
Log.i(TAG,"hello 1111..........");
}
else {
// i.setClass(context, TestingSettings.class);
}
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
这就启动了新的apk