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