使用am发启广播
adb shell am broadcast -a android.provider.Telephony.SECRET_CODE -d android_secret_code://28346
广播端:
import static other.packages.Intents.SECRET_CODE_ACTION // ="android.provider.Telephony.SECRET_CODE "
Intent intent = new Intent(Intents.SECRET_CODE_ACTION,
Uri.parse("android_secret_code://" + "28346"));
context.sendBroadcast(intent);广播接收端 方式1:
<receiver android:name="MyReceiver" >
<intent-filter>
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data android:scheme="android_secret_code" android:host="28346" />
</intent-filter>
</receiver>
广播接收 方式2:public void onReceive (Context context, Intent intent)
{
//.,....
if (intent.getAction().equals(SECRET_CODE_ACTION)) {
String host = intent.getData().getHost();
if (host.equals("767*3855") && !isKeyStringBlocked()) {
// do something
}
}
adb shell am broadcast -a android.provider.Telephony.SECRET_CODE -d android_secret_code://767*3855