Problem: the android program is packaged with phonegap for full screen display on the device;
We sometimes need to set the activity to full screen display. Generally, you can set the full screen display effect in two ways.
1. You can set it in the code,
Set in the Code (as follows)
Public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); // you can specify the value of requestwindowfeature (window. feature_no_title); // sets full screen getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen); setcontentview (R. layout. main );}
However, you must note that if you set it in the Code, the two sections of code with no title and full screen should be placed in front of setcontentview (R. layout. Main. Otherwise, an error is reported.
Second, set it in the manifest configuration file.
The Code is as follows:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.andyidea" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" /> <application android:icon="@drawable/icon"
android:label="@string/app_name" android:theme="@android:style/android.NoTitleBar.Fullscreen"> <activity android:name=".login.LoginActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
This setting does not solve the problem. We found that the phonegap package was not full screen.
Add a line of code in method 1
Getwindow (). clearflags (windowmanager. layoutparams. flag_force_not_fullscreen); // clear flag this line is the focus of requestwindowfeature (window. feature_no_title); getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen );
Complete code:
Phonegap package complete code
Public class saleactivity extends droidgap {Private Static final string target_url = "http:"; private context = This; @ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setfullscreen (); If (checknetwork () {super. init (); super. appview. revoke AchE (true); super. setbooleanproperty ("loadinwebview", true); super. setintegerproperty ("loadurltimeoutvalu E ", 10000); // the loading time is super. setintegerproperty ("splashscreen", R. drawable. splash); // boot page super. loadurl (target_url, 8000); // sets the page super. setbooleanproperty ("keeprunning", true); // keep running in the background} else {showdialog () ;}// check the network status private Boolean checknetwork () {connectivitymanager connmgr = (connectivitymanager) getsystemservice (context. connectivity_service); networkinfo = connmgr. getactiven Etworkinfo (); If (networkinfo! = NULL & networkinfo. isconnected () & networkinfo. isavailable () {return true;} else {return false;} // the pop-up dialog box protected void showdialog () {alertdialog. builder = new Builder (context); builder. setmessage ("the network is not connected currently. Are you sure you want to set it? "); Builder. settitle ("prompt"); builder. setpositivebutton ("OK", new onclicklistener () {@ override public void onclick (dialoginterface dialog, int which) {saleactivity. this. finish (); intent = new intent ("android. settings. wireless_settings "); startactivity (intent) ;}}); builder. setnegativebutton ("cancel", new onclicklistener () {@ override public void onclick (dialoginterface dialog, int which) {saleactivity. this. finish () ;}}); builder. create (). show () ;}// full screen (no title bar or status bar) protected void setfullscreen () {getwindow (). clearflags (windowmanager. layoutparams. flag_force_not_fullscreen); // clear the flag requestwindowfeature (window. feature_no_title); getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen );}}