使用android 隐藏命令

本文介绍如何在Android应用中实现秘密拨号代码的功能。通过定义特定的拨号代码,可以触发应用程序执行特定操作,例如启动一个隐藏的Activity。文章详细展示了如何在AndroidManifest.xml中配置接收器以及编写对应的BroadcastReceiver类。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

添加秘密程序,通过拨号启动
AndroidManifest.xml
<receiver android:name=".secret">
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data android:scheme="android_secret_code" android:host="1234"/>
</intent-filter>
</receiver>

secret.java
public class secret extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
String host = intent.getData() != null ? intent.getData().getHost() : null;

if (Intents.SECRET_CODE_ACTION.equals(action) && "1234".equals(host)) {
//start an acitivity
}
}
}

SECRET_CODE_ACTION
public static final String SECRET_CODE_ACTION Broadcast Action: A "secret code" has been entered in the dialer. Secret codes are of the form *#*##*#*. The intent will have the data URI:

android_secret_code://<code>



Intent intent = new Intent("android.provider.Telephony.SECRET_CODE",
Uri.parse("android_secret_code://" + "4636"));
sendBroadcast(intent);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值