让我的应用程序启动时的秘密code进入?我的、启动时、应用程序、秘密

2023-09-05 23:27:28 作者:㊣ル㈧經~帅

我将如何让我的应用程序启动时,一个秘密的code,如 *#*#12345#*#* 输入到拨号?

How would I make my app launch when a secret code, such as *#*#12345#*#* is entered into the dialer?

我找不到在Android文档的解决方案。

I couldn't find a solution in the Android docs.

推荐答案

这是我是如何做的:

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

I changed my main activity to have no intent-filters:

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

然后我做了一个广播接收器,意图筛选器操作: android.provider.Telephony.SECRET_ code

然后添加数据给它。整个事情是如下:

I then added data to it. The entire thing is below:

<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类,火的意图来启动该活动。

Once done, make a class (I made the Launch class in my main class, extending BroadCast Receiver), then in the onReceive class, fire an intent to launch the activity.

然后键入 *#*#(秘密code)#*#* 进入拨号器将启动应用程序。

Then typing *#*#(secret code)#*#* into the dialer will launch the app.