Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何创建可使用拨号板启动的应用程序_Android - Fatal编程技术网

Android 如何创建可使用拨号板启动的应用程序

Android 如何创建可使用拨号板启动的应用程序,android,Android,我想知道如何用拨号板上的一些代码启动我的android应用程序。就像你 ##3214789650## 从您的galaxy启动angryGps应用程序。 如何实现这一点 谢谢。试试这个。使用广播接收器收听呼出电话号码: Manifest.xml uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/> <receiver android:name=".OutgoingCallReceiver


我想知道如何用拨号板上的一些代码启动我的android应用程序。就像你 ##3214789650## 从您的galaxy启动angryGps应用程序。
如何实现这一点


谢谢。

试试这个。使用广播接收器收听呼出电话号码:

Manifest.xml

uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>


<receiver android:name=".OutgoingCallReceiver"> 
<intent-filter> 
<action android:name="android.intent.action.NEW_OUTGOING_CALL"/>
</intent-filter> 
</receiver>

您正在寻找的是contacts应用程序的一部分,虽然很可能每个制造商的实现都是相同的,但我不确定这一点

启动新活动的意图由文件中的函数handleSecretCode传递。代码片段是

    static boolean handleSecretCode(Context context, String input) {

    // Secret codes are in the form *#*#<code>#*#*

    int len = input.length();

    if (len > 8 && input.startsWith("*#*#") && input.endsWith("#*#*")) {
        Intent intent = new Intent(Intents.SECRET_CODE_ACTION,
                Uri.parse("android_secret_code://" + input.substring(4, len - 4)));
        context.sendBroadcast(intent); 
您需要做的是为intent action Intents.SECRET_CODE_action和uri android_SECRET_CODE://“CODE”注册广播接收器,并在广播接收器中启动应用程序


您还可以看到一些应用程序是如何实现的,emulator上的一个代码是*.*.*.*.*.

从未尝试过,但我认为,这将在上面的每个#之后使用一些Broadcast receiver.add*完成number@awais您尝试过使用'ACTION\u NEW\u OUTGOING\u CALL'BroadcastReceiver吗?@noli您能给出一些示例或提示吗?thanks@imrankhan很好,但是如果您尝试上面的代码,您实际上没有按下绿色的调用按钮,那么当您点击最后一颗星时,应用程序就会启动。还有其他建议吗?尽管我会在用你提到的广播接收器实现它之后让你知道。谢谢^^看起来不错,但是有没有办法防止拨号板在呼叫
BroadcastReceiver
后尝试拨打此“电话号码”?@TonythePony yes in your receiver call this:setResultData(null);很好,但我相信这只适用于有序广播,对吗?@TonythePony是的,从它返回一些结果集的工作方式来看,我认为它是可行的。@imrankhan这是一个解决办法,但它会起作用,感谢您提供的示例。和清单文件。希望对你有帮助。
    static boolean handleSecretCode(Context context, String input) {

    // Secret codes are in the form *#*#<code>#*#*

    int len = input.length();

    if (len > 8 && input.startsWith("*#*#") && input.endsWith("#*#*")) {
        Intent intent = new Intent(Intents.SECRET_CODE_ACTION,
                Uri.parse("android_secret_code://" + input.substring(4, len - 4)));
        context.sendBroadcast(intent);