简体   繁体   中英

Android app installs but doesn't show up in app tray

I'm building a time logging application and i have created the main layout. I tried to debug my application on my phone Samsung Galaxy S and it starts fine, but if i close it and want to run it again it's not in my app drawer. It shows up in Settings->Programs->Manage and in Recent when holding down the home button.

Here is the manifest.xml

<?xml version="1.0" encoding="utf-8"?>  
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.doweb.timelog" android:versionCode="1">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar">
        <activity android:name="MainActivity" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN">
                <category android:name="android.intent.category.LAUNCHER">
            </category></action></intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="8">
</uses-sdk>
</manifest>

I think your closing </action> tag in the intent-filter is in the wrong position. Should look like:

<intent-filter>
         <action android:name="android.intent.action.MAIN" > </action>
         <category android:name="android.intent.category.LAUNCHER"> </category>
</intent-filter>

That filter is a signal to the system that this activity should be visible in the app-drawer. When it's not correct or present, the activity won't be visible.

Usually it's best to use closed empty elements to prevent this error:

<intent-filter>
         <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

You're also missing a . in front of your activitys class. This always relates to your apps package name. It will internally be joined to packagename + classname . Therefore the dot, otherwise it would result in com.doweb.timelogMainActivity , which is obviously not the correct reference. So it should be android:name=".MainActivity" .

你的活动的名字就像这个android:name =“。MainActivity”,你可以尝试一下

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM