我有一个Android应用程序,列出已安装的应用程序并在项目点击时启动它们。我想禁用从我的应用程序访问NotificationBar。当用户从我的应用程序启动“浏览器”应用程序时,可以向下拖动通知吧,他/她可以改变gps,wifi等的设置......我试过这个
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
但它仅适用于我的活动。如何为我的整个应用程序禁用通知栏?
先谢谢
答案 0 :(得分:1)
您可以在AndroidManifest.xml中使用主题:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
这会隐藏标题栏
<activity android:name=".YourClassName"
android:theme="@android:style/Theme.NoTitleBar"/>
答案 1 :(得分:1)
在XML中设置应用程序的主题:
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
答案 2 :(得分:0)
请参阅下面的代码。我应用了您在问题中指定的代码,我的通知栏已隐藏。您将无法禁用外部浏览器应用程序的通知栏
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);
}
}
}