Reputation: 1163
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.
Why is this? Please could anyone tell me what the issue is?
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
:
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.
Upvotes: 0
Views: 980
Reputation: 1163
I discovered that this is due to changes in 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.
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.
Upvotes: 1
Reputation: 7979
Try using full package name
<receiver android:name="com.something.something.CodeReceive" >
Upvotes: 0