Android Development Learning Note-splash Screen display

Source: Internet
Author: User

Post code:

<?XML version= "1.0" encoding= "Utf-8"?><Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Com.frank.mobilesafe"Android:versioncode= "1"Android:versionname= "1.0" >    <USES-SDKandroid:minsdkversion= "Ten"android:targetsdkversion= "+" />    <ApplicationAndroid:allowbackup= "true"Android:icon= "@drawable/ic_launcher"Android:label= "@string/app_name"Android:theme= "@style/apptheme" >        <ActivityAndroid:name=". Mainactivity "Android:label= "@string/app_name" >                   </Activity>        <ActivityAndroid:name=". Splashactivity "Android:theme= "@android: Style/theme.notitlebar"Android:label= "@string/title_activity_splash" >             <Intent-filter>                <ActionAndroid:name= "Android.intent.action.MAIN" />                <categoryAndroid:name= "Android.intent.category.LAUNCHER" />            </Intent-filter>        </Activity>    </Application></Manifest>

Processing class:

 PackageCom.frank.mobilesafe;Importandroid.app.Activity;ImportAndroid.content.pm.PackageInfo;ImportAndroid.content.pm.PackageManager;Importandroid.content.pm.PackageManager.NameNotFoundException;ImportAndroid.os.Bundle;ImportAndroid.view.Window;ImportAndroid.widget.TextView; Public classSplashactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Requestwindowfeature (window.feature_no_title);//Remove title barSetcontentview (R.layout.activity_splash); TextView tv_version=(TextView) Findviewbyid (r.id.tv_version);    Tv_version.settext (GetVersion ()); }    protectedstring GetVersion () {string Versionstr= ""; Packagemanager Packmanger=Getpackagemanager (); Try{PackageInfo Info= Packmanger.getpackageinfo (Getpackagename (), 0); Versionstr= Info.versionname;//Get version number}Catch(namenotfoundexception e) {//TODO auto-generated Catch blockVersionstr = "";        E.printstacktrace (); }        returnVersionstr; }}

Configuration file:

 <ApplicationAndroid:allowbackup= "true"Android:icon= "@drawable/ic_launcher"Android:label= "@string/app_name"Android:theme= "@style/apptheme" >        <ActivityAndroid:name=". Mainactivity "Android:label= "@string/app_name" >                   </Activity>        <ActivityAndroid:name=". Splashactivity "Android:theme= "@android: Style/theme.notitlebar"Android:label= "@string/title_activity_splash" >             <Intent-filter>                <ActionAndroid:name= "Android.intent.action.MAIN" />                <categoryAndroid:name= "Android.intent.category.LAUNCHER" />            </Intent-filter>        </Activity>    </Application>
Summarize:

1, in the setting splash screen display time, originally thought is uses the ImageView, finally understood to know is uses the android:background= "@drawable/luncher_bg"

2, the new technology is mainly to use the Packmanger class to read about the version of some information

3, in the removal of the title in the configuration file added Android:theme= "@android: Style/theme.notitlebar" After the program in the start of the error, finally see Logcat down the process to find the original

Activity By default inherits the Actionbaractivity class, changes it to activity and the program starts normally

Android Development Learning Note-splash Screen display

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.