This question already has answers here:
is it possible to hide the system bar
(5 answers)
Closed 9 years ago.
I am developing an application for tablet only, where the requirement is to run the app on the full screen of the tablet.
So please help me how to hide the tab bar because that apps is totally related to examination.
So back press, home and and other buttons are not required..
You cant hide that. How should a user quit your app without the bottom bar?
You can hide the bottom bar. But there is no direct method available. First you need to root the tab and then run the process to hide the bar. If you root the tab then the warranty will be void. And there is no unique method to root the tab (getting super user privileges), different tabs have different methods. And once you have rooted the tab, then you should do
//hide status bar
process = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 79 s16 com.android.systemui"});
process.waitFor();
//show status bar
process = Runtime.getRuntime().exec(new String[]{"am","startservice","-n","com.android.systemui/.SystemUIService"});
process.waitFor();
But this will work only for HoneyComb. For ICS and above try to find the code to hide status bar.
You can try below approach.
public class ActivityName extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// remove title
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
Or you can do it via your AndroidManifest.xml file:
<activity android:name=".ActivityName"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
</activity>
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am developing custom lockscreen app.its working fine in below 4.0 but above 4.0,when we press home button the app stops.is there any solution for this no apps will stop when pressing home button untill unlocking the screen.(like go locker app)
Another way to develop a LockScreen App is by using Views, let me explain it.
First of all you can "disable" in some devices the System lock screen by disabling the KEYGUARD:
((KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE)).newKeyguardLock("IN").disableKeyguard();
You should put this line of code in your Service.
After that you can launch an activity every time the screen goes off:
public class AutoStart extends BroadcastReceiver {
public void onReceive(Context arg0, Intent arg1) {
if(arg1.getAction().equals("android.intent.action.SCREEN_OFF")) {
Intent localIntent = new Intent(arg0, LockScreen.class);
localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
localIntent.addFlags(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
arg0.startActivity(localIntent);
}
}
}
If you read the documentation for WindowManager.LayoutParams.TYPE_SYSTEM_ERROR it explains that is a type of internal system error windows, appear on top of everything they can. In multiuser systems shows only on the owning user's window.
So now you have an activity on top of everything, but a press in HOME button will exit the activity.
Here is where the Views make their appearance. You can inflate a view from a layout resource and add it to the WindowManager as a TYPE_SYSTEM_ERROR, so will be on top of everything. And since you can control when to remove this View, the best place is in onDestroy of your Activity, because pressing the HOME button will only pause your activity, and the view will still be visible.
public WindowManager winManager;
public RelativeLayout wrapperView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_SYSTEM_ERROR,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL|
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
this.winManager = ((WindowManager)getApplicationContext().getSystemService(WINDOW_SERVICE));
this.wrapperView = new RelativeLayout(getBaseContext());
getWindow().setAttributes(localLayoutParams);
View.inflate(this, R.layout.lock_screen, this.wrapperView);
this.winManager.addView(this.wrapperView, localLayoutParams);
}
public void onDestroy()
{
this.winManager.removeView(this.wrapperView);
this.wrapperView.removeAllViews();
super.onDestroy();
}
To avoid the notification bar of showing I added the flags FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL | FLAG_LAYOUT_IN_SCREEN to consume all pointer events.
Not forget to add these two lines to your manifest:
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
From here you just need to add the logic of your Lock Screen app to let the user use his smartphone :)
A custom launcher is basically an app (you can make it behave like a grid, list, implement your own drag and drop etc) then, you only need to add these lines to the intent filter of the main activity, with this done, after you install your app and press the home button your app will appear in the list of available homescreens.
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
What i cant find is a way to replace the lock screen, and hacks like disabling the lock screen on the phone and using an activity in a custom launcher isn't actually replacing the lockscreen ^^
You can use the below method to disable the Home key in android :
#Override
public void onAttachedToWindow() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
I am developing on a Samsung Galaxy S4 5.0 and what worked for me was simply changing getWindow().setFlags(..) to getWindow().addFlags(..)
I think first of all you should ask yourself if you really want to hijack the home key. Sometimes you may want it. But I think placing the app on the Android lock screen, letting the home key act normally and letting the underlying Android lock screen take care of password-protecting the device is what you actually want in a lot of cases (unless you want to change the way this is done by default).
Bottom line, letting an app be displayed on the Android lock screen comes pretty close to writing your own custom lock screen. And is decidedly easier since you don't have to manage passwords yourself. Not to mention it's safer and more reliable since you don't hijack the home key.
I did it like this and it works very well. You can see the details here:
show web site on Android lock screen
The question is about displaying a website on the lock screen, since that's what I was interested in, but the answer is more general, it works with any app.
You can see here an app that's on Google Play and has been written like this:
https://play.google.com/store/apps/details?id=com.a50webs.intelnav.worldtime
This question already has answers here:
how to disable notification bar for an android application? [duplicate]
(3 answers)
Closed 9 years ago.
The user can launch other installed applications from my application and back to my activity when exiting launched application.I want to disable notification bar(showed status of wifi,gps,bluetooth etc...) or pulling down of notification bar throughout my application .
It works for my application when setting requestWindowFeature(Window.FEATURE_NO_TITLE); But when launching other applications from my application ,possible to pull down Notification bar.
Is there any way to handle this?
Is it possible remove all notifications from Notification bar while my application is running?
How to make Notification bar not accessible from my application(a service is running throughout the application for checking currently running applications)?
Thanks in Advance
No it is not possible, and thank the lord for that.
Would be pretty horrible if one rogue app would block my notification bar in all other parts of the system and other apps.
You could us a theme in your AndroidManifest.xml:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
or use the following code snippet:
public class Activity
extends android.app.Activity
{
#Override
public void onCreate(android.os.Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
I want to hide system bar for tablet device. I searched a lot but not succeed. I added image for it.
I found some solution like
View v = findViewById(R.id.view_id);
v.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
but I dont know how to use it
And I know that is possible as http://forum.xda-developers.com/showthread.php?t=1228046 Can any one know how to do this ?
Code snippet to show/hide status bar on rooted android tablets
To hide:
Process proc = null;
String ProcID = "79"; //HONEYCOMB AND OLDER
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH){
ProcID = "42"; //ICS AND NEWER
}
try {
proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "service call activity "+ProcID+" s16 com.android.systemui" });
} catch (Exception e) {
Log.w("Main","Failed to kill task bar (1).");
e.printStackTrace();
}
try {
proc.waitFor();
} catch (Exception e) {
Log.w("Main","Failed to kill task bar (2).");
e.printStackTrace();
}
To show:
Process proc = null;
try {
proc = Runtime.getRuntime().exec(new String[] { "su", "-c", "am startservice -n com.android.systemui/.SystemUIService" });
} catch (Exception e) {
Log.w("Main","Failed to kill task bar (1).");
e.printStackTrace();
}
try {
proc.waitFor();
} catch (Exception e) {
Log.w("Main","Failed to kill task bar (2).");
e.printStackTrace();
}
Finally after searching lots of time I got some alternativ for my requirement.
I know this is not a good idea for a programmer to back off from this situation but for my time limit I used this way...
I found this link and application which fullfil my requirement
http://www.42gears.com/blog/2012/04/how-to-hide-bottom-bar-in-rooted-android-3-0-tablets-using-surelock/
please visit this once if you want this type of requirement in your application ....
Thanks to all for helping me in my problem...
It is not possible to hide the system bar. There is nothing in the API that allows for it. This is because the user always needs access to the home and back keys in case the app freezes or does something goofy where the user just needs to get out of the app. You can only hide the action bar.
There is a workaround to disable menu bar in all most all tablets without rooting. But this is bit tricky, but it works clean. Several well known apps in the market at the moment using this strategy to achieve this disable menu bar feature for their apps.
Grant admin privilege.
Set password & lock the device using device admin profile api
Then load what ever the UIs on top of the native lock screen. (Of course this will show background lock screen whenever a transition happens between activities. But if logic is organized well, then it will be smooth & less noticed by the user)
When need to enable back, reset password to "" using resetPassword("", 0) of device policy manager object.
var width = innerWidth;
var height = innerHeight;
I think this code will help for you.its not hide the tablet bar
but your application fit on any device you can use this
(I used this code in javascript for cord ova mobile application)
You just need combination of SYSTEM_UI_FLAG_IMMERSIVE_STICKY | SYSTEM_UI_FLAG_HIDE_NAVIGATION | SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN. For example, if you use opengl and glSurfaceView is you surface:
glSurfaceView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
Swipe at bottom to see the bottom bar, it will hide again after few seconds.
I believe its the same for all android devices.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
I also found another solution but this of course is just a separate app called surelock.
http://onkarsingh.sys-con.com/node/2184158
EDIT:
The above code doesn't hide the Tablet Bar. I'll leave my answer up for those looking to hide the System Bar in another Android Device.
You can't hide it but you can simply disable it, except home. Try this link. . Using SYSTEM_UI_FLAG_LOW_PROFILE you can dim your system bar and using onWindowFocusChanged() can take the focus and collapse it.
I found a trick on a galaxy tab for use it as a kiosk
according to the developer guide of Samsung
You can ask your app to be over the lock system and ask the return button to go back to a start activity/view of your app.
I done this for a web View app
#Override
public void onBackPressed() {
//here asking to go back to home page
mWebView.loadUrl(mHomepageUrl);
}
for asking to stay up from the lock system, on the onCreate method :
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
and then when you click on the power button twice , you found back your application , and only the back button is active on the status bar
So the only way is to reboot the tablet (and so you can use the classic lock system with a code to open tablet)
Can be useful if the power button is not accible by visitor , or if your are the only one who have the unlock code
// Put code on onCreate method of your activity / fragment
#Override
#SuppressLint("NewApi")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.activity_main);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
In order to create a Kiosk app in android you need the following:
- Override the onkeydown
#Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode==KeyEvent.KEYCODE_BACK || keyCode==KeyEvent.KEYCODE_HOME){
startActivity(new Intent(this,MainActivity.class));
return true;
}
return super.onKeyDown(keyCode, event);
}
Then make your activity a launcher activity in order to override the home button. (in the manifest)
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
No need for weird locker apps that asks a million permissions. You don't have to root your phone.
I'm trying to do an Android-Tablet app for presentations on trade fairs etc. I don't want to upload the app to the app store, only use it on my tablet.
I try to run the app in ful screen mode (without status bar) with:
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Works great. I try to disable the home button with:
#Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
}
in my OnCreate-Method. Works great.
But if I try to use both in one app, only disabling the home button still works, any idea what i can do about this?
Thank you!
Try declaring the activity as fullscreen in AndroidManifest.xml, and then doing what you already do to capture the home button
<activity android:name="..." android:label="..."
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" />
i create a lockscreen application.. this application is triggered by SMS.. when a SMS containing command was received, it will display a lock screen activity.
my lockscreen activity is using TYPE_KEYGUARD for disabling a home screen button. When device screen turn off and then i turn it on again, my problem is status bar / notification bar still appear on my screen. this is a problem because the user still can access some program through status bar / notification bar even the device is being locked. so i want to dissapear this status bar / notification bar so that the user (theft) can't access that device anymore..
Please help me to solve this..
I think what you're trying to do is programmatically set an activity as fullscreen. If so, consider the following:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Source: http://www.androidsnippets.com/how-to-make-an-activity-fullscreen
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
}
requestWindowFeature(Window.FEATURE_NO_TITLE);
only disables the activity's title bar, not the notification bar at the top.
Use this theme in android manifest for your activity :
"Theme.NoTitleBar.Fullscreen"
did work for me.
It hides the notification bar.
On Android 4.0 and lower
Option 1:
<application
...
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
...
</application>
Option 2:
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// If the Android version is lower than Jellybean, use this call to hide
// the status bar.
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setContentView(R.layout.activity_main);
}
...
}
on Android 4.1 and Higher
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
And for Android 4.6(Api 19) and higher use the Immersive Full-Screen
Mode
Reference from Google