Android 拨打密码时启动隐藏应用程序
我的要求是在输入密码时启动一个隐藏的应用程序 MainActivity.javaAndroid 拨打密码时启动隐藏应用程序,android,service,broadcast,receiver,Android,Service,Broadcast,Receiver,我的要求是在输入密码时启动一个隐藏的应用程序 MainActivity.java public class MainActivity extends BroadcastReceiver { String dialed_number; @Override public void onReceive(Context context, Intent intent) { dialed_number = intent.getStringE
public class MainActivity extends
BroadcastReceiver {
String dialed_number;
@Override
public void onReceive(Context context, Intent intent)
{
dialed_number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
if(dialed_number.equals("*0*1235#"))
{
Intent appIntent = new Intent(context, MainActivity.class);
appIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(appIntent);
setResultData(null);
}
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tuto.bala.helloworld" >
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver
android:name=".MainActivity">
</receiver>
</application>
</manifest>
当我运行该项目时,会出现以下异常:
连接问题无效的mmi代码android
有人能帮忙吗
问候,,
巴拉
异常:连接问题无效的mmi代码android 要检测传出电话事件,您应该在AndroidManifest.xml中使用新的_outgoing _call操作注册广播:
我使用了相同的代码,当我们得到的拨号号码是一个不包括*的号码时,它就起作用了,。在清单文件中,我们必须像这样声明接收者
<receiver android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
别忘了在你的舱单上注册这个接收人
<receiver android:name="MyOutgoingCallHandler">
<intent-filter >
<action android:name="android.intent.action.NEW_OUTGOING_CALL"/>
</intent-filter>
</receiver>
如果您想以呼叫魔法号码的方式启动应用程序,使用广播接收器拨打电话非常简单,您可以从正确的号码应用程序获得解决方案。异常:连接问题mmi代码无效android。您能帮助我解决此异常吗。我已经挣扎了将近一个星期了,这是相当艰难的urgent@user38843:尝试传递相同的有效号码,如1234563,然后检查是否获得相同的问题?谢谢您的回复。拨打这个号码会触发一个电话:亲爱的哈努曼,这个代码对普通号码也不起作用。我试着拨1435号。事情很紧急,请你帮忙好吗。谢谢你看到这一点,你会得到充分的澄清提供的网页是从stackoverflow删除,你可以提供另一个网址或任何相同的教程。非常感谢Hanuman非常感谢Hanuman,你的解决方案非常有效。非常感谢您的帮助。我在emulator中测试了该应用程序。它工作正常,但该应用程序在设备中失败。拨打号码会触发呼叫。问题是什么?
<receiver android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
public class MyOutgoingCallHandler extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// Extract phone number reformatted by previous receivers
String phoneNumber = getResultData();
if (phoneNumber == null) {
// No reformatted number, use the original
phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
}
if(phoneNumber.equals("1234")){ // DialedNumber checking.
// My app will bring up, so cancel the broadcast
setResultData(null);
// Start my app
Intent i=new Intent(context,MainActivity.class);
i.putExtra("extra_phone", phoneNumber);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
<receiver android:name="MyOutgoingCallHandler">
<intent-filter >
<action android:name="android.intent.action.NEW_OUTGOING_CALL"/>
</intent-filter>
</receiver>
String phone=getIntent().getStringExtra("extra_phone");
if(!phone.equals(null)){
Toast.makeText(getBaseContext(), phone, Toast.LENGTH_LONG).show();
}