`

AndroidManifest.xml注意事项

阅读更多

一、target SDK version

    Android Runtime和Dalvik会根据target SDK version决定是否工作在『兼容模式』下,所谓兼容模式,就是关闭了新版本中各种新机制和体验优化的状态。targetSdkVersion如果设置很低,就等于是关闭了所有高版本的新特性和机制,包括『屏幕自适应』、『硬件加速』。

为了保证各个版本的兼容性,及时使用到新特性,targetSdkVersion因随Android最新版本的发布而持续提高,以保证在各个Android版本的设备上都能获得完整的体验。

Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details

    去除警告你只要把android:targetSdkVersion="17"里面的17改为最新版本就行了

 

二、<application>中的debuggable=”true”

    当debuggable打开时,除了更易暴露在攻击之下,SDK tools(包括ProGuard)也不会进行一些针对发布版本可以进行的优化,比如移除dex包中的代码调试信息(符号名、行号等),移除DEBUG和VERBOSE级别的日志输出。这些对App发布版本的容量和性能都有直接的影响。

    Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically assign one

 

三、 <uses-permission>写在<application>之后

    表面上看没有什么问题,但却埋下了一些<application>内部属性正确生效的隐患。

    The <application> tag should appear after the elements which declare which version you need, which features you need, which libraries you need, and so on. In the past there have been subtle bugs (such as themes not getting applied correctly) when the <application> tag appears before some of these other elements, so it's best to order your manifest in the logical dependency order

 

四、 配置两个主Activity

    在AndroidManifest.xml文件里可以配置两个主Activity如下:

     <activity

            android:name=".activity.StartActivity"

            android:configChanges="orientation|keyboardHidden"

            android:launchMode="singleTop"

            android:theme="@android:style/Theme.Translucent"

            android:windowSoftInputMode="stateHidden|adjustUnspecified" >

            <intent-filter>

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

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

            </intent-filter>

        </activity>

       <activity

            android:name=".activity.StartActivity1"

            android:configChanges="orientation|keyboardHidden"

            android:launchMode="singleTop"

            android:theme="@android:style/Theme.Translucent"

            android:windowSoftInputMode="stateHidden|adjustUnspecified" >

            <intent-filter>

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

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

            </intent-filter>

        </activity>

        这时在手机的程序任务列表会生成两个启动task图标,分别对应上面定义的两个主Activity

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics