简体   繁体   中英

Setting Default Activity Android

Trying to create a default activity (the one that loads when the app starts).

My code in the manifest.xml is as follows:

 <activity
            android:name=".Start"
            android:label="@string/title_activity_start" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

However this is not working. Anyone have any ideas? The activity I previously set as default is loading instead.

here is my complete Manifest

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.samstone.ringoffire"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="16" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
         <activity
            android:name=".Start"
            android:label="@string/title_activity_start" >
           <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
        </activity>
        <activity
            android:name="com.samstone.ringoffire.RingOfFire"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >

        </activity>
        <activity
            android:name="com.samstone.ringoffire.AddRules"
            android:label="@string/title_activity_add_rules" >
        </activity>


    </application>

</manifest>

It loads up RingOfFire activity as default.

The activity I previously set as default is loading instead.

Reboot the device or emulator in question. The home screen can elect to cache this sort of information and therefore may not detect your changes in <intent-filter> values.

像开始其他活动一样输入您的开始活动的全名,并摆脱android.intent.category.DEFAULT

I had the same problem. I'm using IDEA. In Run => Edit Configurations... you can set which Activity will launch first (you can set there a default Activity that will solve your problem).

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