Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
197 views
in Technique[技术] by (71.8m points)

android - Application without app icon

I plan to do an app which contains only one activity and without any app icon, where I need to open this activity by using the keypad. Say for example, whenever you dial 12345 my application activity should open without an app icon. Is this possible in Android? How?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just remove android.intent.category.LAUNCHER from your main Activity in AndroidManifest.xml

And you cannot open app by dialing *#*#12345#*#* because in order to do that you have to write a receiver for following action

<action android:name="android.provider.Telephony.SECRET_CODE" />

Then you can open your app by firing an Intent from that broadcast receiver. But android does not permit this until your app is *System app.*

Following is the code that will help you Change activity in Manifest to have no intent filters like

<activity
            android:name=".MyApp"
            android:label="@string/title_activity_parent_trap"
            android:theme="@android:style/Theme.Holo" >
        </activity>
<receiver android:name=".MyApp$Launch" >
            <intent-filter>
                <action android:name="android.provider.Telephony.SECRET_CODE" />

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

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.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...