简体   繁体   English

如何通过意图而不是主要活动将应用程序设置为全屏显示

[英]How to set the application to fullscreen from an Intent, Not from the main activity

My Application Has 4 Tabs, Each tab creates a subview ( intent ) now I have a handler for options/menu button within each intent , of the menu items is "Toggle Fullscreen" this doesn't work as the intent isn't the parent view while the activity containing the TabHost is the parent View, Now I need to know how do I Set the whole app. 我的应用程序有4个选项卡,每个选项卡都会创建一个子视图(意图),现在我在每个意图中都有一个用于选项/菜单按钮的处理程序,菜单项为“切换全屏”,这不起作用,因为意图不是父项视图,而包含TabHost的活动是父视图,现在我需要知道如何设置整个应用程序。 to FullScreen mode or how to Refer to the Parent Activity to Set the full screen mode through it. 进入全屏模式,或如何参考父活动通过它设置全屏模式。

Here's a snippet of my code 这是我的代码片段

    public class MainActivity extends TabActivity {

    public void toggleFullScreen(){
    // This has the code to set App. to full screen
    }

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        Intent myIntent = new Intent(this, MywebviewActivity.class);
        tabHost.addTab(             
                tabHost.newTabSpec("SomeName")
                .setIndicator("Some Title")
                .setContent( myIntents ));

Now I need to set fullscreen mode from "MywebviewActivity" not from my MainActivity 现在,我需要从“ MywebviewActivity”而不是从MainActivity设置全屏模式

check this 检查这个

add this in your webview activity 将此添加到您的webview活动中

    Intent i=getIntent();
    if(i!=null)
    {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

modify code in your MainActivity as following 如下修改MainActivity代码

Intent myIntent = new Intent(this, MywebviewActivity.class);

 intent.putExtra("isFullScreen", true);




now in onCreate() method of MywebviewActivity write code as following 现在在MywebviewActivity onCreate()方法中编写代码,如下所示

put "setContentView(R.layout.main);" 把“ setContentView(R.layout.main);” method below of this code as following : 此代码下面的方法如下:

public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);

    Intent intent=getIntent();
    boolean isfullScreen =  intent.getBooleanExtra("isFullScreen", false);


        if(isfullScreen )
        {
            requestWindowFeature(Window.FEATURE_NO_TITLE);
            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
        }

setContentView(R.layout.main);


}

not it will work 不行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从活动到应用的“意图” - “Intent” from Activity to Application 如何从不同的Activity获取主要启动活动的Intent? - How to get Intent of main launch Activity from a different Activity? 如何在不使用Intent的情况下从子级活动跳至主要活动? - How to jump to main activity from subchild activity without using Intent? 如何使用意图将值从主活动传递到子活动? - How to pass a value from a main activity to a sub activity using intent? 如何从Main(ActionBarActivity)意图活动获取ActionBar - How can I get ActionBar from Main(ActionBarActivity) intent Activity 如何在Android中使用菜单从Main活动中打开Intent(MapView) - How to open an Intent (MapView) from the Main activity with menu in Android 将意图从主要活动发送到两个片段 - send intent from main activity to two fragment 从自定义适配器(而不是从主要活动)开始意图 - 如何实现活动结果以重新加载适配器中的视图? - Starting an intent from custom adapter (not from the main activity) - how to implement on activity result to reload views in adapter? 如何从另一个活动中将主题设置为主要活动? - How to set theme to Main Activity from another activity? Android:从意图活动返回主活动后执行方法 - Android: execute method after returning to main activity from intent activity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM