2012-07-30 36 views

回答

9

这是我做的:

我改变了我的主要活动有没有意图过滤器:

<activity 
      android:name=".ParentTrap" 
      android:label="@string/title_activity_parent_trap" 
      android:theme="@android:style/Theme.Holo" > 
     </activity> 

我那么做的意图筛选器操作的广播接收器:android.provider.Telephony.SECRET_CODE

然后我添加了数据。整个事情是下面:

<receiver android:name=".ParentTrap$Launch" > 
      <intent-filter> 
       <action android:name="android.provider.Telephony.SECRET_CODE" /> 

       <data 
        android:host="(secret code)" 
        android:scheme="android_secret_code" /> 
      </intent-filter> 
     </receiver> 

一旦这样做,使一个类(我在主类所作的启动类,延伸广播接收器),然后在类的onReceive,火的意图开始练习。

然后在拨号器中输入*#*#(secret code)#*#*将启动应用程序。

+0

这不适用于三星Galaxy Note GT-N7000与Android 4.1.2。我们是否还需要做其他事情才能使其发挥作用? – Manish 2013-09-20 18:03:19

+0

@Manish是在你尝试之前打开的应用程序吗? – 2013-09-24 08:46:34

+0

是的,我确实创建了一个空白的活动。请参阅我的相关问题:http://stackoverflow.com/questions/18901339/android-provider-telephony-secret-code-reserved-for-system-apps和请帮助,如果你可以。 – Manish 2013-09-24 17:50:18

6

这个动作创建一个广播接收器:

在你发现the dialed number的花絮。

编辑:这是用于广播接收机的tutorial

+0

不是那样.....但它可能要做。 – 2012-07-30 15:14:00

+0

我不认为你能够拦截简单的拨号动作,而不需要实际拨打电话... – eftokay83 2012-07-30 15:15:35

+0

啊,我在谈论*#*#密码,但我想通了如何使用它们:) – 2012-07-30 15:21:57

0

虚拟广播接收者,也许你应该注册适当的活动意图。例如Intent.ACTION_CALL看起来沾沾自喜。问题是如何过滤意图只收回这一个specyfic号码。我怀疑它是这样的(我根据我的文档已经找到gesing):

<action name=".YourAction"> 
    <intent-filter . . . > 
     <action android:name="android.intent.action.CALL" /> 
     <!-- data is crutial here, you have to figuire it out exacly yourself --> 
     <data android:scheme="tel" android:path="yourSpecyficSecretCode" /> 
    </intent-filter> 
</action> 

herehere。使用LogCat查看什么exacly intent contatins,然后您可以正确地过滤它。

相关问题