android 拨号启动秘密app 无界面 receiver

仅以下代码生成的app在android 4.0无法工作,app需要至少一个activity,或者如上添加 <category >,而在android2.2可以工作。

1.声明在manifest.xml里面声明receiver:
<receiver android:name=".StartSettings">
  <intent-filter>
     <action android:name="android.provider.Telephony.SECRET_CODE" /> 
    <data android:host="0556" android:scheme="android_secret_code" /> 
    <data android:host="0557" android:scheme="android_secret_code" /> //可以有多个data
 </intent-filter>
</receiver>

 

2.JAVA代码:

public class startSettings extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String host;
if (intent.getData() != null) {
host = intent.getData().getHost();
} else return;
if (host.equals("0556")) {
//TODO,启动一个程序,如下启动RootExplorer
Intent it = new Intent("android.intent.action.MAIN");
it.setClassName("com.speedsoftware.rootexplorer","com.speedsoftware.rootexplorer.RootExplorer");
context.startActivity(it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));//必须要FLAG_ACTIVITY_NEW_TASK
} else {
//TODO
}
}
}

3.键盘拨号启动:*#*#0557#*#*  ,0556就是manifest.xml里面的android:host="0556"




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值