file:AndroidManifest.xml
<receiver
android:name=".FactoryModeReceiver"
android:exported="true" >
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data
android:host="42678"
android:scheme="android_secret_code" />
</intent-filter>
</receiver>
file:FactoryModeReceiver.java
public class FactoryModeReceiver extends BroadcastReceiver {
private static final String TAG = "FM/SECRET_CODE";
// process *#*#42678#*#*
private final Uri mFmUri = Uri.parse("android_secret_code://42678");
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(
android.provider.Telephony.Intents.SECRET_CODE_ACTION)) {
Uri uri = intent.getData();
Log.i(TAG, "getIntent success in if");
if (uri.equals(mFmUri)) {
Intent intentFm = new Intent(context, FactoryModeActivity.class);
intentFm.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Log.i(TAG, "Before start Facotory activity");
context.startActivity(intentFm);
} else {
Log.i(TAG, "No matched URI!");
}
} else {
Log.i(TAG, "Not SECRET_CODE_ACTION!");
}
}
}
cmd:
adb shell am broadcast -a android.provider.Telephony.SECRET_CODE -d "android_secret_code://42678"
code:
Intent intent = new Intent(SECRET_CODE_ACTION,
Uri.parse("android_secret_code://
42678
" ));
mContext.sendBroadcast(intent);
file:AndroidManifest.xml
<receiver
android:name=".FactoryModeReceiver"
android:exported="true" >
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data
android:host="42678"
android:scheme="android_secret_code" />
</intent-filter>
</receiver>
file:FactoryModeReceiver.java
public class FactoryModeReceiver extends BroadcastReceiver {
private static final String TAG = "FM/SECRET_CODE";
// process *#*#42678#*#*
private final Uri mFmUri = Uri.parse("android_secret_code://42678");
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(
android.provider.Telephony.Intents.SECRET_CODE_ACTION)) {
Uri uri = intent.getData();
Log.i(TAG, "getIntent success in if");
if (uri.equals(mFmUri)) {
Intent intentFm = new Intent(context, FactoryModeActivity.class);
intentFm.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Log.i(TAG, "Before start Facotory activity");
context.startActivity(intentFm);
} else {
Log.i(TAG, "No matched URI!");
}
} else {
Log.i(TAG, "Not SECRET_CODE_ACTION!");
}
}
}
cmd:
adb shell am broadcast -a android.provider.Telephony.SECRET_CODE -d "android_secret_code://42678"
code:
Intent intent = new Intent(SECRET_CODE_ACTION,
Uri.parse("android_secret_code://
42678
" ));
mContext.sendBroadcast(intent);