[英]Secret code BroadCast receiver not working at all
I am in the process of developing an application (mainly for private use), that I want to implement a secret code system in. 我正在开发一个应用程序(主要供私人使用),我想在其中实现一个秘密代码系统。
I have setup the following broadcast receiver, however when I enter *#*#887755#*#*
it doesn't launch the receiver. 我已经设置了以下广播接收器,但是当我输入
*#*#887755#*#*
它不会启动接收器。
Why is this? 为什么是这样? Please could anyone tell me what the issue is?
请任何人告诉我问题是什么?
AndroidManifest.xml
: AndroidManifest.xml
:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.liamwli.spyware.usertrack"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="10" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".ProcessSMS"
android:label="@string/app_name" >
</activity>
<activity
android:name=".ActivityConfig"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.liamwli.spyware.usertrack.ACTIVITYCONFIG" />
</intent-filter>
</activity>
<receiver android:name=".CodeReceive" >
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data
android:host="887755"
android:scheme="android_secret_code" />
</intent-filter>
</receiver>
</application>
</manifest>
CodeReceive.java
: CodeReceive.java
:
package com.liamwli.spyware.usertrack;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
class CodeReceive extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
Toast.makeText(arg0, "Worked", Toast.LENGTH_SHORT).show();
Intent i = new Intent(arg0, ActivityConfig.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
arg0.startActivity(i);
}
}
I do not receive any logcat output, and I have tried adding android:exported="true"
to the receiver, however it makes no difference. 我没有收到任何 logcat输出,并且尝试将
android:exported="true"
到接收器,但是没有区别。
I discovered that this is due to changes in Android 3.1+ 我发现这是由于Android 3.1+中的更改
Broadcast Receivers will now not work until the app is launched on Android 3.1+, as such this app won't work. 在该应用在Android 3.1+上启动之前,广播接收器现在将无法使用,因此该应用将无法使用。
The way to bypass this is to install it as a system application, or allow the user to launch it manually, and then hide the icon. 绕过此方法的方法是将其安装为系统应用程序,或允许用户手动启动它,然后隐藏图标。
尝试使用完整的软件包名称
<receiver android:name="com.something.something.CodeReceive" >
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.