更改應用程序的啓動活動

我已經建立了個人應用程序的肉和內臟,但我想添加一個不一樣的活動,這將是一個起點(一種登陸屏幕)。 linux

情侶問題: android

  • 1我對如何在活動之間切換有一個至關不錯的處理(基於這篇文章: http//www.linux-mag.com/id/7498 ),但我不肯定如何建立一個新的(與日食)app

  • 2建立新活動後, 如何將其設置爲應用程序的默認活動? 我認爲我能夠只更改類的名稱......可是有更優雅的方法來處理它(可能在AndroidManifest.xml )? spa


#1樓

<application
    android:icon="@drawable/YOUR_ICON"    <!-- THIS ICON(IMAGE) WILL BE SHOWN IN YOUR APPS -->
    android:label="MY APP NAME " >    <!-- HERE LABEL(APP NAME) -->
    <activity
        android:name=".application's starting activity"  <!-- (.)dot means current dir, if your activity is in another package then give full package name ex: com.xxx.Activity  -->
        android:label="LABEL FOR ACTIVITY "
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

#2樓

這很簡單。 在您的Manifest文件中執行此操做。 code

<activity
    android:name="Your app name"
    android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.HOME" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
</activity>

#3樓

這很容易解決。 xml

  • 對Launcher活動的更改也存儲在Debug配置中
  • 轉到Run > Debug Configurations並編輯設置。
  • Run > Edit Configurations下的Intellij中也有相似的設置選擇Run default Activity ,它將再也不以這種方式保存設置。

#4樓

只需轉到AndroidManifest.xml文件並添加以下 get

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

而後保存並運行你的android項目。 string


#5樓

若是您使用的是Android Studio,則可能以前已選擇另外一個要啓動的活動it

單擊「 Run > Edit configuration ,而後確保選中「 啓動默認活動」io

啓動默認活動

相關文章
相關標籤/搜索