This question already has an answer here:
-
Hide Notification bar
8 answers
I have an android application which lists installed applications and launch them on item click.I want to disable accessing NotificationBar from my application.ie,When user launch 'Browser' application from my application,it is possible to drag down the notification bar and he/she can change settings of gps,wifi etc...I tried this
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
But it works only for my activity.How to disable Notification Bar for my whole application?
Thanks in Advance
Set a theme on the Application in your XML:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
You could us a theme in your AndroidManifest.xml:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
This will hide the title bar
<activity android:name=".YourClassName"
android:theme="@android:style/Theme.NoTitleBar"/>
See my code below. I applied the code you specified in your question and my notification bar is hidden. You won't be able to disable the notification bar for external browser applications
public class ContentBrowser extends Activity {
private LinearLayout _progressBarLayout;
@Override
public 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.browserlayout);
Bundle receiveBundle = this.getIntent().getExtras();
initialize(receiveBundle.getString("url"));
}
@SuppressLint("SetJavaScriptEnabled")
private void initialize(String url) {
WebView webView = (WebView) findViewById(R.id.browserView);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
webView.getSettings().setDomStorageEnabled(true);
_progressBarLayout = (LinearLayout) findViewById(R.id.browserProgressLayout);
final Activity activity = this;
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
// Activities and WebViews measure progress with different scales.
// The progress meter will automatically disappear when we reach 100%
activity.setProgress(progress * 1000);
}
});
webView.setWebViewClient(new browserClient());
if (url != null && !"".equals(url))
webView.loadUrl(url);
}
@Override
public void onBackPressed() {
finish();
}
public class browserClient extends WebViewClient
{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
_progressBarLayout.setVisibility(View.GONE);
}
}
}