Cordova 设置全屏及退出全屏切换

设置全屏在super.init();之前

最后才退出全屏。

以下为具体代码:

package com.agile.ittm;

import android.os.Bundle;

import android.view.Window;

import android.view.WindowManager;

import org.apache.cordova.*;

public class ITTM extends CordovaActivity 

{

    @Override

    public void onCreate(Bundle savedInstanceState)

    {

        super.onCreate(savedInstanceState);

        setFullscreen();//设置全屏

        super.init();

        // Set by <content src="index.html" /> in config.xml

       

        super.setIntegerProperty("splashscreen", R.drawable.splash);

        

        super.loadUrl(Config.getStartUrl(), 3000);

        //super.loadUrl(Config.getStartUrl());

        //super.loadUrl("file:///android_asset/www/index.html")

        quitFullScreen();//退出全屏

    }

    

    //设置全屏

    public void setFullscreen() {  

        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);//清除FLAG  

        requestWindowFeature(Window.FEATURE_NO_TITLE);  

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  

                       WindowManager.LayoutParams.FLAG_FULLSCREEN);  

   }  

    //退出全屏

    public void quitFullScreen(){

     final WindowManager.LayoutParams attrs = getWindow().getAttributes();

     attrs.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);

     getWindow().setAttributes(attrs);

     getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

     }

    

    

    

}

上一篇:Android(java)学习笔记242:多媒体之设置全屏的方法


下一篇:android sqlite datetime demo