没有应用程序图标

Jam*_*ttu 5 android

我打算做一个只包含一个活动且没有任何应用程序图标的应用程序,我需要使用键盘打开此活动.比如说,每当您拨打12345我的应用程序时,应该打开没有应用程序图标的活动.这在Android中可行吗?怎么样?

Vis*_*ale 12

只需从AndroidManifest.xml中的主Activity中删除android.intent.category.LAUNCHER即可

并且您无法通过拨号打开应用程序,*#*#12345#*#*因为为了做到这一点,您必须编写接收器以执行以下操作

<action android:name="android.provider.Telephony.SECRET_CODE" />
Run Code Online (Sandbox Code Playgroud)

然后,您可以通过从该广播接收器触发Intent来打开您的应用.但是在你的应用程序是*System app之前,android不允许这样做.*

以下代码将帮助您将Manifest中的活动更改为没有类似的意图过滤器

<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>
Run Code Online (Sandbox Code Playgroud)

完成后,创建一个类(我在我的主类中创建了Launch类,扩展了BroadCast Receiver),然后在onReceive类中启动了一个启动活动的意图.

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


ina*_*ruk 4

您必须为的元素android:icon中的属性指定可绘制资源。来自文档applicationAndroidManifest.xml

该属性必须设置为对包含图像的可绘制资源的引用(例如“@drawable/icon”)。没有默认图标。


但指定的可绘制对象不必是图标。它可以定义为资源中的颜色:

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <drawable name="color_icon">#ff0000</drawable>
</resources>
Run Code Online (Sandbox Code Playgroud)

然后在您的中指定它AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>  
    <application android:icon="@drawable/color_icon" ...>
       ...
    </application>  
</manifest> 
Run Code Online (Sandbox Code Playgroud)

您将在应用程序启动板中看到类似以下内容:

在此输入图像描述