android 怎样通过暗码启动应用程序

 我来答
育知同创教育
2016-11-03 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
展开全部
参考如下:
首先在manifest.xml中 添加 <receiver >相关的代码
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".PhoneGuide"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="Cipher">
<intent-filter>
<action
android:name="android.provider.Telephony.SECRET_CODE"/>
<!-- *#*#1001#*#* -->>
<data android:scheme="android_secret_code"

android:host="1001"/>
</intent-filter>
</receiver>
</application>
然后Cipher.java的代码如下
[java] view plain copy
package feng.PhoneGuide;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* 通过暗码启动重置activity的处理
* */
public class Cipher extends BroadcastReceiver{
public Cipher(){

}
@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
if(arg1.getAction().equals
("android.provider.Telephony.SECRET_CODE")){
Intent i = new Intent(Intent.ACTION_MAIN);
i.setClass(arg0, PhoneGuide.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
arg0.startActivity(i);
}
}
}
然后在打电话的界面输入 *#*#1001#*#* 就可以启动相应的应用程序了。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式