android项目中,添加工程指令
2016-12-14 13:42
232 查看
在 packages/apps/Dialer/src/com/android/dialer/SpecialCharSequenceMgr.java 里面 handleSecretCode方法会发送暗码广播 只要以*#*#开头#*#*结尾都会把中间的暗码发送出去
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("#*#*")) {
if ("4636".equals(input.substring(4, len - 4))) {
//return false;
}
final Intent intent = new Intent(SECRET_CODE_ACTION,
Uri.parse("android_secret_code://" + input.substring(4, len - 4)));
context.sendBroadcast(intent);
return true;
}
return false;
}
在vendor/sim/CIT/AndroidManifest.xml 中会注册接收这个广播 来启动CIT界面
<receiver android:name=".EntranceReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE"/>
<data android:scheme="android_secret_code" android:host="248"/>
<data android:scheme="android_secret_code" android:host="76388378"/>
<data android:scheme="android_secret_code" android:host="8266"/>
<data android:scheme="android_secret_code" android:host="49"/>
<data android:scheme="android_secret_code" android:host="1030"/>
<data android:scheme="android_secret_code" android:host="0"/>
</intent-filter>
</receiver>
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("#*#*")) {
if ("4636".equals(input.substring(4, len - 4))) {
//return false;
}
final Intent intent = new Intent(SECRET_CODE_ACTION,
Uri.parse("android_secret_code://" + input.substring(4, len - 4)));
context.sendBroadcast(intent);
return true;
}
return false;
}
在vendor/sim/CIT/AndroidManifest.xml 中会注册接收这个广播 来启动CIT界面
<receiver android:name=".EntranceReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE"/>
<data android:scheme="android_secret_code" android:host="248"/>
<data android:scheme="android_secret_code" android:host="76388378"/>
<data android:scheme="android_secret_code" android:host="8266"/>
<data android:scheme="android_secret_code" android:host="49"/>
<data android:scheme="android_secret_code" android:host="1030"/>
<data android:scheme="android_secret_code" android:host="0"/>
</intent-filter>
</receiver>
相关文章推荐
- Eclipse添加Android项目工程后res文件夹下layout/values/drawable文件不可见
- 在android目录添加自己的项目工程
- cordova---cordova常见指令,创建工程,编译运行项目,添加删除平台、插件,模拟器
- android项目 添加
- Android 程式开发:(九)使用活动栏 —— 9.2添加ActionBar项目
- Android项目添加外部jar文件
- Android 系统包和项目工程说明
- 用Ant编译Android项目工程
- Java SE工程项目使用相对路径添加jar包
- Android开发实战三之导入现有Android工程项目
- 如何在eclipse的android工程中添加外部javadoc.jar包,方便开发
- 如何将android2.1源码添加到自己的项目当中
- 在已经建好的工程项目中需要添加BCG功能!
- 【转】如何将TapkuLibrary框架添加到Xcode4工程项目中
- 导入别人的项目时,工程中不自动生成Android Dependencies的解决方式
- Android Fragment---给动作栏添加项目
- Android游戏引擎《Rokon》学习笔记一:为你的项目添加Rokon框架
- 对android项目反向工程的方法
- Android游戏引擎《Rokon》学习笔记一:为你的项目添加Rokon框架
- Android项目中如何正确的引入第三方jar包(工程)