1.按键广播接受
public class SecretCodeReceiver extends BroadcastReceiver {
/*接受按键指令*/
@Override
public void onReceive(Context context, Intent i) {
// TODO Auto-generated method stub
Intent intent=new Intent(context,AfterSaleCardActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}
2.在AndroidManifest.xml中注册接受器
<receiver android:name="SecretCodeReceiver">
-
<
intent-filter
>
<
action
android:name
="
android.provider.Telephony.SECRET_CODE
"
/>
<
data
android:scheme
="
android_secret_code
"
android:host
="
369
"
/>
</
intent-filter
>
</
receiver
>
OK,现在输入*#*#369#*#*就可以进入你想要的界面了
按键广播接收实现
本文介绍了一种通过按键广播接收器启动特定活动的方法。通过创建一个名为SecretCodeReceiver的BroadcastReceiver子类并重写onReceive方法,可以实现当输入特定代码(*#*#369#*#*)时启动指定的AfterSaleCardActivity。此外,还在AndroidManifest.xml中注册了此接收器,并设置了相应的intent-filter。
868

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



