通过Dialer拨号盘输暗码启动某个apk
来源:互联网 发布:系统垃圾清理软件 编辑:程序博客网 时间:2024/05/21 05:21
通过拨号暗码 启动某个apk
首先\packages\apps\Dialer\src\com\android\dialer\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 boolean handleSecretCode(Context context, String input) {
// Secret codes are in the form *#*#<code>#*#*
int len = input.length();
if (len > 8 && input.startsWith("*#*#") && input.endsWith("#*#*")) {
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;
}
构建一个EMStartReceiver 在AndroidManifest.xml中定义 <intent-filter> 对应暗码
<receiver android:name="EMStartReceiver" >
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data
android:host="xxxxx"
android:scheme="android_secret_code" />
</intent-filter>
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data android:scheme="android_secret_code" android:host="xxxxx" />
</intent-filter>
</receiver>
EMStartReceiver 代码如下 放在源码中编译
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import java.lang.String;
import com.android.internal.telephony.TelephonyIntents;
import android.os.SystemProperties;
public class EMStartReceiver extends BroadcastReceiver {
private static final String TAG = "EMStartReceiver";
public EMStartReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
String host = null;
Uri uri = intent.getData();
if (uri != null) {
host = uri.getHost();
} else {
Log.d(TAG,"uri is null");
return;
}
Intent i = new Intent(Intent.ACTION_MAIN);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if("xxxxx".equals(host) || "xxxxx".equals(host)){
i.setClass(context, EngineerModeActivity.class);
context.startActivity(i);
}
}
}
- 通过Dialer拨号盘输暗码启动某个apk
- 源码分析之Android通过Dialer实现暗码启动
- android 如何通过拨号盘暗码启动你的应用
- 拨号盘暗码功能,暗码启动应用
- Android 拨号盘暗码启动应用程序
- 使用暗码启动内置APK
- 拨号盘增加暗码
- android中实现暗码启动apk【一】
- Android中实现暗码启动APK【二】
- linphoned的拨号盘的dialer
- android 怎样通过暗码启动应用程序
- 【Dialer】自定义暗码进入测试模式
- Android暗码启动
- Android暗码启动
- android 暗码启动分析
- Android为拨号盘dialer定制声音DTMF Tones
- Android为拨号盘dialer定制声音DTMF Tones
- Android为拨号盘dialer定制声音DTMF Tones
- Android开发 之 矢量图动画SVG(细节版)
- linux grep命令详解
- Mr.Smile填坑记——BaseRecyclerViewAdapterHelper使用时条目复用问题(各种状态混乱)
- 从MVC到前后端分离(REST-个人也认为是目前比较流行和比较好的方式)
- CSS常用样式总结
- 通过Dialer拨号盘输暗码启动某个apk
- Java:按值传递与按引用传递
- Apache引入mod_evasive模块防止ddos攻击
- 17暑假多校联赛2.11 HDU 6055 Regular polygon
- iOS开发中数据库常用的语句
- 最大流-SAP算法
- easyUI下datagrid嵌套显示
- android使用UncaughtExceptionHandler捕获全局异常(闪退)
- sdut 1265 马拦过河卒