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

被折叠的 条评论
为什么被折叠?



