1

我有一个 android 应用程序,它列出了已安装的应用程序并在单击项目时启动它们。我想禁用从我的应用程序访问通知栏。即,当用户从我的应用程序启动“浏览器”应用程序时,可以向下拖动通知栏,他/她可以更改gps、wifi等的设置...我试过了

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                                    WindowManager.LayoutParams.FLAG_FULLSCREEN);

但它只适用于我的活动。如何为我的整个应用程序禁用通知栏?

提前致谢

4

3 回答 3

1

在 XML 中的应用程序上设置主题:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
于 2013-04-02T10:19:47.733 回答
1

您可以在您的 AndroidManifest.xml 中添加一个主题:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

这将隐藏标题栏

<activity android:name=".YourClassName"
android:theme="@android:style/Theme.NoTitleBar"/>
于 2013-04-02T10:19:15.083 回答
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);
        }
    }

}
于 2013-04-02T10:32:42.047 回答