Android simple pop-up Screen

Source: Internet
Author: User

Reference http://www.cnblogs.com/royenhome/archive/2010/05/05/1727971.html

 

Mainmenu. Java

 

Package Com. Demo;
Import Android. App. activity;
Import Android. OS. Bundle;
Public   Class Mainmenu Extends Activity {

@ Override
Protected VoidOncreate (bundle savedinstancestate ){
Super. Oncreate (savedinstancestate );
This. Setcontentview (R. layout. Main );
}

}

 

 

 
Test. Java

 

Code Package Com. Demo;

ImportAndroid. App. activity;
ImportAndroid. content. intent;
ImportAndroid. OS. Bundle;
ImportAndroid. util. log;
ImportAndroid. View. keyevent;

Public class test extends activity {

private long m_dwsplashtime = 3000 ;< br> private Boolean m_bpaused = false ;
private Boolean m_bsplashactive = true ;

/**Called when the activity is first created.*/
@ Override
Public VoidOncreate (bundle savedinstancestate ){
Super. Oncreate (savedinstancestate );
Setcontentview (R. layout. Splash );

Thread splashtimer = New Thread ()
{
Public   Void Run (){
Try {
// Wait Loop
Long MS = 0 ;
While (M_bsplashactive && MS < M_dwsplashtime ){
Sleep ( 100 );

If(!M_bpaused)
MS+ =100;
}

Startactivity ( New Intent ( " Com. Google. App. Splashy. clearsplash " ));
}
Catch (Exception ex ){
Log. E ( " Splash " , Ex. getmessage ());
}
Finally {
Finish ();
}
}
};
Splashtimer. Start ();
}

@ override
protected void onpause () {
super . onpause ();
m_bpaused = true ;< BR >}

@ Override
Protected VoidOnresume (){
Super. Onresume ();
M_bpaused=False;
}

@ Override
Public   Boolean Onkeydown ( Int Keycode, keyevent event ){
Super . Onkeydown (keycode, event );
Switch (Keycode ){
Case Keyevent. keycode_menu:
M_bsplashactive = False ;
Break ;
Case Keyevent. keycode_back:
/* Two exit Methods */
/* System. Exit (0 ); */
/* Android. OS. process. killprocess (Android. OS. process. mypid ()); */
Android. OS. process. killprocess (Android. OS. process. mypid ());
Break ;
Default :
Break ;
}
Return   True ;
}
}

 

 

 
 

Androidmanifest. xml configuration is very important.

 

Code

    <?  XML version = "1.0" encoding = "UTF-8"  ?>  
< Manifest Xmlns: Android = "Http://schemas.android.com/apk/res/android"
Package = "Com. Demo"
Android: versioncode = "1"
Android: versionname = "1.0" >
< Application Android: icon = "@ Drawable/icon" Android: Label = "@ String/app_name" >

< Activity Android: Name = "Test" Android: Label = "@ String/app_name" >
< Intent-Filter >
< Action Android: Name = "Android. Intent. Action. Main" />
< Category Android: Name = "Android. Intent. Category. launcher" />
</ Intent-Filter >
</ Activity >

< Activity Android: Name = ". Mainmenu" Android: Label = "@ String/app_name" >
< Intent-Filter >
< Action Android: Name = "Com. Google. App. Splashy. clearsplash" />
< Category Android: Name = "Android. Intent. Category. Default" />
</ Intent-Filter >
</ Activity >


</ Application >


</ Manifest >

 

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.