Can any one please tell me any way to hide status bar completely just for my application on all activities. My application only runs on android tabs with 4.0.3 Android. I actually want to remove the back, home and all the other click listeners on the status bar or just completely hide it. The requirement behind this is that if once my application starts on a tab it stays on until user switches off the device device and there should not be any exit point. I will be grateful for your humble response. I have added android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" manifest.xml.Still not able to disable the status bar. My activity class is given below
package com.plugin.myapp;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.CordovaWebViewClient;
import org.apache.cordova.DroidGap;
import org.apache.cordova.CordovaChromeClient;
import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;
public class MainActivity extends DroidGap {
private static MainActivity instance;
// private WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
//getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
getWindow().getDecorView().setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
super.loadUrl("file:///android_asset/www/tdc_tutorial.html");
}
// handler for the background updating
Handler progressHandler = new Handler()
{
public void handleMessage(Message msg)
{
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
};
@Override
public void onConfigurationChanged(Configuration newConfig) {
// TODO Auto-generated method stub
super.onConfigurationChanged(newConfig);
System.out.println("onConfigurationChanged");
}
@Override
public void init() {
super.init((CordovaWebView) new WebView(this), new GWTCordovaWebViewClient(this), new CordovaChromeClient(this));
}
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
//super.onBackPressed();
}
/* (non-Javadoc)
* @see org.apache.cordova.DroidGap#onConfigurationChanged(android.content.res.Configuration)
*/
}
and my manifest.xml is given below
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.plugin.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.INTERNET" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"
android:resizeable="true"
android:anyDensity="true"
/>
<application
android:icon="@drawable/ic_launcher"
android:label="Android Test"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:screenOrientation="sensorLandscape"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Take a look at GMD HideBar for ICS . I used it on my 4.0.3 tablet and it works very good! if you use dex2jar to get jar from apk file, I could import jar file in your buildpath and use function SystemUI.hidebar
to hide or SystemUI.showbar
to show :)
For devices without hardware key, unless you "Root" device, there's no way to completely hide the bar. You can, however, put it in "low profile" mode using setSystemUIVisiblity .
By default, you shouldn`t remove the statusbar, because it is a service from the Android UI. Then Google let you hide it, however if the user swipes it up, it will come back.
But, yes it is possible to do if you have root access on the device.
This code can hide and show the StatusBar by killing it`s proccess and calling it back again.
package com.example.statusbar;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
public class MainActivity extends Activity {
String commandToExecute;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
commandToExecute = "/system/xbin/su";
executeShellCommand(commandToExecute);
Button btHideStatusBar = (Button) findViewById(R.id.buttonHide);
Button btShowStatusBar = (Button) findViewById(R.id.buttonShow);
btHideStatusBar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
commandToExecute = "/system/xbin/su -c /system/bin/service call activity 42 s16 com.android.systemui";
executeShellCommand(commandToExecute);
}
});
btShowStatusBar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
commandToExecute = "/system/xbin/su -c /system/bin/am startservice -n com.android.systemui/.SystemUIService";
executeShellCommand(commandToExecute);
}
});
}
private boolean executeShellCommand(String command) {
try {
Runtime.getRuntime().exec(command);
return true;
} catch (Exception e) {
return false;
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.