场景设想:如果你需要隐藏你的apk icon,并通过android的拨号盘启动你的apk应用;
android 2.3源码修改位置:
android源码目录\packages\apps\Contacts\src\com\android\contacts\SpecialCharSequenceMgr
以下是定义了*#*#(……)#*#*格式以及*#(……)*#格式;类似的输入格式都会广播SECRET_CODE_ACTION,
/**
* 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 boolean handleSecretCode(Context context, String input) {
// Secret codes are in the form *#*#<code>#*#*
int len = input.length();
Log.i("secrectcode", "len= "+len);
if (len > 8 && input.startsWith("*#*#") && input.endsWith("#*#*"))
{
Intent intent = new Intent(Intents.SECRET_CODE_ACTION,
Uri.parse("android_secret_code://" + input.substring(4, len - 4)));
context.sendBroadcast(intent);
return true;
}
else if (len ==6 && input.startsWith("*#") && input.endsWith("*#")){
Intent intent = new Intent(Intents.SECRET_CODE_ACTION,
Uri.parse("android_secret_code://" + input.substring(2, len - 2)));
context.sendBroadcast(intent);
return true;
}
return false;
}
指定你的data,与你的receiver对应;data和action共同限定了过滤条件;
<receiver android:name=".ATSBroadcastReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data android:scheme="android_secret_code" android:host="66" />
<data android:scheme="android_secret_code" android:host="67" />
</intent-filter>
</receiver>-----------------------------------------------
ps:属于android源码修改;但个人觉得data的限定可以使广播的接收者更加精确;data也可以用来区分程序的不同模式;
本文介绍如何通过修改Android源码实现隐藏应用图标,并使用拨号盘特定代码启动应用的方法。涉及*#*#及*#形式的秘密代码处理流程,以及如何在AndroidManifest.xml中配置对应的receiver。
;&spm=1001.2101.3001.5002&articleId=8098499&d=1&t=3&u=fc090397f7cb4ff5ab084ac4cf2ed160)
1万+

被折叠的 条评论
为什么被折叠?



