安卓设置默认首先启动Activity

在学习的时候我们觉得建立新的项目很费时间,也费内存,所以我们很多时候都是在一个项目下面创建 多个activity来试验

但是如何设置默认首先启动的Avtivity  来验证我们的新实验是否成功呢?

 在app.src.main下面有个Androidmanifest.xml  里面记录了你项目有哪些activity 当然也记录了那个是默认启动项

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.pro.first">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">

        </activity>
        <!--
 ATTENTION: This was auto-generated to add Google Play services to your project for
     App Indexing.  See https://g.co/AppIndexing/AndroidStudio for more information.
        -->
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

         <activity android:name=".Main2Activity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />

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

</manifest>

  

我们直接将下面这段代码放在你想默认启动的activity中间就行了 就像上面的代码 默认首先启动的是main2activity

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

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

  

posted on 2017-03-19 09:17  焕金剑  阅读(14256)  评论(0编辑  收藏  举报

导航