I want to ask about webview :
I can't capture full page in webview. I can only capture the view that appears on the screen only, as I want to capture the full page. How to?
This is my webview :
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
WebView.enableSlowWholeDocumentDraw();
}
setContentView(R.layout.main_activity);
final WebView webview = (WebView) findViewById(R.id.WebViewLayout);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient() {
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(webview, url);
}
});
webview.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webview.setDrawingCacheEnabled(true);
webview.loadUrl("https://example.com");
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
Toast.makeText(this, "Bluetooth is not available",
Toast.LENGTH_LONG).show();
finish();
}
}
and this is to convert into bitmap
private void Print_BMP(){
Bitmap mBitmap = Bitmap.createBitmap(imageViewPicture.getDrawingCache());
int nMode = 0;
int nPaperWidth = 384;
if(width_58mm.isChecked())
nPaperWidth = 384;
if(mBitmap != null)
{
byte[] data = PrintPicture.POS_PrintBMP(mBitmap, nPaperWidth, nMode);
SendDataByte(Command.ESC_Init);
SendDataByte(Command.LF);
SendDataByte(data);
SendDataByte(PrinterCommand.POS_Set_PrtAndFeedPaper(30));
SendDataByte(PrinterCommand.POS_Set_Cut(1));
SendDataByte(PrinterCommand.POS_Set_PrtInit());
}
}
and this is for keylistener
private void KeyListenerInit() {
btnScanButton = (Button)findViewById(R.id.button_scan);
btnScanButton.setOnClickListener(this);
width_58mm = (RadioButton)findViewById(R.id.width_58mm);
width_58mm.setOnClickListener(this);
imageViewPicture = (WebView) findViewById(R.id.WebViewLayout);
imageViewPicture.setOnClickListener(this);
}
Capture, scroll, capture, repeat as necessary.
Then assemble the individual images if you need to after that.
The add-in browser tools that provide this functionality appear to work in this same way.
Related
In My activity I have a Webview at the top which plays the video inside it.
below the Webview I have a list of videos to select. For Android versions before Oreo when I select the new video it always plays in the Webview. But in Oreo it doesn't work, It always plays the first video Which i Selected. I have read the document of Oreo it says that
Calling clearFormData() no longer has any effect.
I am looking for some alternative but couldn't find any solution. Below is the my work which I have done so for
private void initViews() {
toolbar = findViewById(R.id.toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(getString(R.string.app_name));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
onBackPressed();
}
});
}
recyclerView = findViewById(R.id.recycler_view);
progressBar = findViewById(R.id.progressBar3);
initWebView();
if (recyclerView != null) {
initRecyclerView(model);
}
AdView adView= findViewById(R.id.ad_view);
admobUtils.loadBannerAd(adView);
}
public void initWebView() {
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.getSettings().setSaveFormData(false);
webView.clearFormData();
webView.clearCache(true);
webView.clearHistory();
webView.setWebViewClient(new WebViewClient() {
#Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
view.clearHistory();
}
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
webView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
RXEventBusUtils.getInstance().postEvent(new MediaPlayerEvent());
}
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
webView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.VISIBLE);
}
});
webView.getSettings().setBuiltInZoomControls(false);
webView.getSettings().setDisplayZoomControls(false);
String htmlData;
if (Constants.isFullScreen) {
htmlData = getHtmlDataLanscape(model.getVideo_url());
} else {
htmlData = getHtmlData(model.getVideo_url());
}
webView.loadData(htmlData, "text/html", null);
}
This is where I am selecting the video from list.
public void selectVideo(){
progressBar.setVisibility(View.VISIBLE);
model = new MyModel();
model = ((SelectVideoEvent) event).getModel();
if (model.getVideo_url() != null && !model.getVideo_url().isEmpty()) {
initRecyclerView(model);
initWebView();
Bundle bundleFire = new Bundle();
Application.getFireBaseInstance().logEvent("video_from_list",bundleFire);
}
}
Please can anybody tell me how to change the webview content in Android Oreo
As clearFormData() no longer has any effect in android version Oreo. The best way is to create a Webview as a new view. For that purpose you should use a frameLayout inside xml file, and inside java file, create webview dynamically and add that webview in framelayout as a view.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<FrameLayout
android:id="#+id/myWeb"
android:layout_width="match_parent"
android:layout_height="200dp"
android:alwaysDrawnWithCache="true" />
</RelativeLayout>
public class TestActivity extends AppCompatActivity {
FrameLayout frameLayout;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
frameLayout = findViewById(R.id.myWeb);
setWebView();
/*setWebViewToLoadData*/
}
public void setWebView(){
frameLayout.removeAllViews();
WebView webView = new WebView(this);
webView.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
frameLayout.addView(webView);
}
}
And indside your selectVideo method call again setWebView
I need a progress bar at the centre of my android webview it must be shown before the page loads and hides when the page is loaded. How can it be done? Can anyone help me?
This is my code for webview:
Bundle extras = getIntent().getExtras();
String title;
final String url;
if (!Datacon.checkInternetConnection(this)) {
Toast.makeText(getApplicationContext(), "Check your Internet Connection!", Toast.LENGTH_LONG).show();
} else {
if (extras != null) {
title = extras.getString("title");
url = extras.getString("url");
TextView text=(TextView) findViewById(R.id.textView1);
text.setText(title);
final WebView myWebView =(WebView)findViewById(R.id.WebView);
myWebView.loadUrl(url);
myWebView.getSettings().setLoadWithOverviewMode(true);
myWebView.getSettings().setUseWideViewPort(true);
myWebView.getSettings().setBuiltInZoomControls(true);
myWebView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
loadingProgressBar=(ProgressBar)findViewById(R.id.progressbar_Horizontal);
myWebView.setWebViewClient(new WebViewClient(){
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
});
Button refresh = (Button) actionBar.getCustomView().findViewById(R.id.but2);
refresh.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
myWebView.loadUrl(url);
}
});
}
}}
}
You need to override a couple of more methods in the WebViewClient :
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
loadingProgressBar.setVisibility(View.VISIBLE);
}
#Override
public void onPageFinished(WebView view, String url) {
loadingProgressBar.setVisibility(View.GONE);
}
I'm assuming loadingProgressBar is a class field.
PS: As a side note I believe you overriding shouldOverrideUrlLoading is unnecessary. The default behaviour is to load the url, as you instruct it to do.
private void initializeProgressBar() {
if (progressBar == null){
progressBar = new ProgressDialog(this);
progressBar.setMessage(Constants.LOADING_MESSAGE);
progressBar.setCancelable(false);
}
}
Handler peogressBar = new Handler(){
public void handleMessage(android.os.Message msg) {
try{
switch (msg.what) {
case 1:
initializeProgressBar();
if(!progressBar.isShowing())
progressBar.show();
break;
case 2:
if (progressBar != null && progressBar.isShowing()) {
progressBar.dismiss();
progressBar = null;
}
break;
}
}catch(Exception e){
e.printStackTrace();
}
};
};
wv_graphLink = (WebView) findViewById(R.id.wv_graphLink);
wv_graphLink.getSettings().setJavaScriptEnabled(true);
wv_graphLink.getSettings().setBuiltInZoomControls(true);
wv_graphLink.getSettings().setSupportZoom(true);
wv_graphLink.setInitialScale(1);
wv_graphLink.getSettings().setLoadWithOverviewMode(true);
wv_graphLink.getSettings().setUseWideViewPort(true);
// wv_graphLink.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
// wv_graphLink.setScrollbarFadingEnabled(false);
peogressBar.sendEmptyMessage(1);
wv_graphLink.setWebChromeClient(new WebChromeClient(){
public void onProgressChanged(WebView view, int progress) {
if(progress == 100){
peogressBar.sendEmptyMessage(2);
}
}
});
wv_graphLink.loadUrl("Your url");
i am a new to android development so dont be harsh
I am creating an android application that contains a webview. The webview has many links to live stream.
After reading various posts, i understand that it is really difficult and complicated (as i have tried) to get the video played in webview itself as webview doesn't have/ support many features for video streaming
My question is: HOW DO I OPEN UP MXPLAYER AND PLAY THE STREAM WHENEVER THE USER SELECTS A SPECIFIC LINK IN THE WEBVIEW?
I am just testing this on my own device so want to keep it specific to mx player as i already have that installed
I have tried the following:
public class WebPageLoader extends Activity {
final Activity activity = this;
WebView webView;
private String pknamepro;
String homePage = "";
String specificWebURL = "";
public WebPageLoader(){
pknamepro = "com.mxtech.videoplayer.pro";
}
private void startMx(String url)
{
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setComponent(new ComponentName("com.mxtech.videoplayer.pro", "com.mxtech.videoplayer.pro.ActivityScreen"));
intent.setData(Uri.parse(url));
intent.putExtra("secure_uri", true);
startActivity(intent);
return;
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webpageloader);
webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setSupportZoom(false);
webView.getSettings().setBuiltInZoomControls(false);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setScrollbarFadingEnabled(true);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDatabaseEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAppCacheEnabled(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
activity.setTitle("Loading...");
activity.setProgress(progress * 100);
if(progress == 100)
activity.setTitle(R.string.app_name);
}
});
webView.setWebViewClient(new WebViewClient() {
#Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
{
Toast.makeText(getApplicationContext(), "Internet connection down" + description, Toast.LENGTH_SHORT).show();
}
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
if (url.contains("rtmp")|| url.contains(specificWebURL) || url.startsWith("rtmpe")|| url.startsWith("udp")) {
startMx(url);
return true;
}
view.loadUrl(url);
return true;
}
});
webView.loadUrl(homePage);
}
protected void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
// Save the state of the WebView
webView.saveState(outState);
}
#Override
protected void onRestoreInstanceState(Bundle savedInstanceState)
{
super.onRestoreInstanceState(savedInstanceState);
// Restore the state of the WebView
webView.restoreState(savedInstanceState);
}
public void onBackPressed() {
if(webView.canGoBack() == true){
webView.goBack();
}else{
webView.goBack();
}
}
As you can see, i have tried it by checking the url as well as tried to hard code the url but neither work.
It seems as if it doesn't do any of the above checks and tries to play the video in webview it self because whenever i click on any of the links, a new page opens saying "Error loading player: No playable sources found" instead of opening mxplayer on my device.
In case someone else has the same question as mine, below is my solution that is working for me.
Intent myIntent;
PackageManager pm = getPackageManager();
try{
myIntent = pm.getLaunchIntentForPackage("com.mxtech.videoplayer.pro");
myIntent.setComponent(new ComponentName("com.mxtech.videoplayer.pro", "com.mxtech.videoplayer.ActivityScreen"));
myIntent.setDataAndType(Uri.parse(url), "application/x-mpegURL");
myIntent.putExtra("secure_uri", true);
myIntent.putExtra(EXTRA_DECODE_MODE, (byte)2);
if (null != myIntent)
this.startActivity(myIntent);
}
catch (ActivityNotFoundException e)
{
Toast.makeText(getApplicationContext(),
" stream not working ",
Toast.LENGTH_LONG).show();
}
I am building an app where a user can see a YouTube video and can see the images for which link is coming from the sever. To play YouTube video embed key's value is coming from server as
`<div id="_cvp_11204"><span>
</span></div>
<script type="text/javascript">
(function(){var a;a=new XMLHttpRequest;a.onreadystatechange=function(){rs=a.readyState;if(4==rs&&200==a.status){var c=JSON.parse(a.responseText),b;for(b in c.payload)if(c.payload.hasOwnProperty(b)){var d=c.payload[b];document.getElementById("cvp"+b).innerHTML=d.view}}};a.open("GET","http://dummyurl.com/media.ids=?11134 ));a.send()})(window);
</script>`
and i am able to play the video also but i am facing few issue in terms of performance.
1) sometimes voices starts but video starts showing after some time.
2) Sometime controls doesn't show up.
3) How can i play the video directly in fullscreen mode?Currently to play the video in full screen mode i have to click on the max control to play it.
As is the activity class for webview
public class MainActivity extends Activity {
protected FrameLayout webViewPlaceholder;
protected WebView webView;
private FrameLayout mContentView;
private MyWebChromeClient mWebChromeClient = null;
private View mCustomView;
private FrameLayout mCustomViewContainer;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.out.println("Oncreate is getting called ---------------------------");
// Initialize the UI
if(savedInstanceState == null){
initUI();
}
}
protected void initUI()
{
// Retrieve UI elements
webViewPlaceholder = ((FrameLayout)findViewById(R.id.webViewPlaceholder));
mContentView = webViewPlaceholder;
// Initialize the WebView if necessary
if (webView == null)
{
System.out.println("webView == null -----------------------------------");
// Create the webview
webView = new WebView(this);
webView.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setAllowContentAccess(true);
webSettings.setDomStorageEnabled(true);
webSettings.setRenderPriority(RenderPriority.HIGH);
webSettings.setUseWideViewPort(false);
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
//--------------------------------------------------------
if (Build.VERSION.SDK_INT < 8) {
webSettings.setPluginsEnabled(true);
} else {
webSettings.setPluginState(PluginState.ON);
}
mWebChromeClient = new MyWebChromeClient();
webView.setWebChromeClient(mWebChromeClient);
// Load the URLs inside the WebView, not in the external web browser
//webView.setWebViewClient(new WebViewClient());
// Load a page
loadWebView("asfas");
}
// Attach the WebView to its placeholder
webViewPlaceholder.addView(webView);
}
private void loadWebView(final String url) {
String s = ReadFromfile("link.txt", MainActivity.this);
s = "<html><body>"+s+"</body></html>";
webView.loadDataWithBaseURL("",Html.fromHtml(s).toString(),"text/html", "UTF-8",null);
}
public String ReadFromfile(String fileName, Context context) {
StringBuilder ReturnString = new StringBuilder();
InputStream fIn = null;
InputStreamReader isr = null;
BufferedReader input = null;
try {
fIn = context.getResources().getAssets()
.open(fileName, context.MODE_WORLD_READABLE);
isr = new InputStreamReader(fIn);
input = new BufferedReader(isr);
String line = "";
while ((line = input.readLine()) != null) {
ReturnString.append(line);
}
} catch (Exception e) {
e.getMessage();
} finally {
try {
if (isr != null)
isr.close();
if (fIn != null)
fIn.close();
if (input != null)
input.close();
} catch (Exception e2) {
e2.getMessage();
}
}
return ReturnString.toString();
}
#Override
public void onConfigurationChanged(Configuration newConfig)
{
if (webView != null)
{
// Remove the WebView from the old placeholder
System.out.println("web view is removed from the holder -------------------------");
webViewPlaceholder.removeView(webView);
}
super.onConfigurationChanged(newConfig);
// Load the layout resource for the new configuration
setContentView(R.layout.activity_main);
// Reinitialize the UI
initUI();
}
#Override
protected void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
System.out.println("onSaveInstanceState -------------------------");
// Save the state of the WebView
webView.saveState(outState);
}
#Override
protected void onRestoreInstanceState(Bundle savedInstanceState)
{
super.onRestoreInstanceState(savedInstanceState);
System.out.println("onRestoreInstanceState -------------------------");
// Restore the state of the WebView
webView.restoreState(savedInstanceState);
}
private class MyWebChromeClient extends WebChromeClient {
FrameLayout.LayoutParams LayoutParameters = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT);
#Override
public void onShowCustomView(View view, CustomViewCallback callback) {
// if a view already exists then immediately terminate the new one
if (mCustomView != null) {
callback.onCustomViewHidden();
return;
}
mContentView.setVisibility(View.GONE);
mCustomViewContainer = new FrameLayout(MainActivity.this);
mCustomViewContainer.setLayoutParams(LayoutParameters);
mCustomViewContainer.setBackgroundResource(android.R.color.black);
view.setLayoutParams(LayoutParameters);
// Sometimes getting remove view first it parent excepetion on moto devices
//webViewPlaceholder.removeView(webView);
mCustomViewContainer.addView(view);
mCustomView = view;
mCustomViewCallback = callback;
mCustomViewContainer.setVisibility(View.VISIBLE);
setContentView(mCustomViewContainer);
}
#Override
public void onHideCustomView() {
if (mCustomView == null) {
return;
} else {
// Hide the custom view.
mCustomView.setVisibility(View.GONE);
// Remove the custom view from its container.
mCustomViewContainer.removeView(mCustomView);
mCustomView = null;
mCustomViewContainer.setVisibility(View.GONE);
mCustomViewCallback.onCustomViewHidden();
// Show the content view.
mContentView.setVisibility(View.VISIBLE);
setContentView(mContentView);
}
}
}
}
And in Manifest also I have set the hardwareaccelarated = true.
here is the video when it starts with controls
and here when i click on maximize button video gets full screen which i want without clicking on max button but video should directly play in fullscreen mode.
So mainly, how I can speed up and increase the performance of my WebView?
My application uses a WebView to display flash video contents. Everything seems to go smoothly
until you try to play full screen on Android ICS devices. It works fine on devices with lower version.
On ICS devices it throws a NullPointerException.
Here is my code:
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginsEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setVerticalScrollbarOverlay(true);
webView.setWebViewClient(new WebViewClient() {
private ProgressDialog pd;
#Override
public void onPageStarted(WebView view, String url,
Bitmap favicon) {
pd = new ProgressDialog(TrainingDetailActivity.this);
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pd.setMessage("Loading");
pd.show();
super.onPageStarted(view, url, favicon);
}
#Override
public void onPageFinished(WebView view, String url) {
this.dismissDialog();
super.onPageFinished(view, url);
}
#Override
public boolean shouldOverrideUrlLoading(WebView view,
String url) {
return false;
}
private void dismissDialog() {
if (pd != null) {
pd.dismiss();
pd = null;
}
}
});
webView.loadDataWithBaseURL(baseUrl, htmlstr, "text/html", "utf-8", null);
After some digging, I found out that in ICS the android.webkit.PluginFullScreenHolder show() method gets called and throws
an NullExceptionPointer. The problem lays there, not on my code.
I tried some work around but none of them works.
- Work around : I added this line:
webView.setWebChromeClient(new WebChromeClient() );
With this work around the NullPointerException does not occur, but the video plays with no sound, and won't switch to
Full screen mode.
I looked around stackoverflow for solutions, the closest which seems to solve my problem is this answer:
https://stackoverflow.com/a/9921073/1503155
But unfortunately the answerer didn't explain what is the variable base in his code snippet and I am still stuck.
My question is, is there a way to work around this bug. Is yes, How?
Thanks in advance.
My boss gave me permission to share this with you.
I had the same issue for a long time before cobbling this together.
Create this as a class, and set the chrome client of your WebView:
WebView.setWebChromeClient(...);
To this:
public class FullscreenableChromeClient extends WebChromeClient {
protected Activity mActivity = null;
private View mCustomView;
private WebChromeClient.CustomViewCallback mCustomViewCallback;
private int mOriginalOrientation;
private FrameLayout mContentView;
private FrameLayout mFullscreenContainer;
private static final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
public FullscreenableChromeClient(Activity activity) {
this.mActivity = activity;
}
#Override
public void onShowCustomView(View view, int requestedOrientation, WebChromeClient.CustomViewCallback callback) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
if (mCustomView != null) {
callback.onCustomViewHidden();
return;
}
mOriginalOrientation = mActivity.getRequestedOrientation();
FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView();
mFullscreenContainer = new FullscreenHolder(mActivity);
mFullscreenContainer.addView(view, COVER_SCREEN_PARAMS);
decor.addView(mFullscreenContainer, COVER_SCREEN_PARAMS);
mCustomView = view;
setFullscreen(true);
mCustomViewCallback = callback;
mActivity.setRequestedOrientation(requestedOrientation);
}
super.onShowCustomView(view, requestedOrientation, callback);
}
#Override
public void onHideCustomView() {
if (mCustomView == null) {
return;
}
setFullscreen(false);
FrameLayout decor = (FrameLayout) mActivity.getWindow().getDecorView();
decor.removeView(mFullscreenContainer);
mFullscreenContainer = null;
mCustomView = null;
mCustomViewCallback.onCustomViewHidden();
mActivity.setRequestedOrientation(mOriginalOrientation);
}
private void setFullscreen(boolean enabled) {
Window win = mActivity.getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN;
if (enabled) {
winParams.flags |= bits;
} else {
winParams.flags &= ~bits;
if (mCustomView != null) {
mCustomView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
} else {
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}
}
win.setAttributes(winParams);
}
private static class FullscreenHolder extends FrameLayout {
public FullscreenHolder(Context ctx) {
super(ctx);
setBackgroundColor(ctx.getResources().getColor(android.R.color.black));
}
#Override
public boolean onTouchEvent(MotionEvent evt) {
return true;
}
}
}
Thanks for upstairs' code
Host's problem I was encountered。
In Activity I resoled like that。
#Override
public void onBackPressed() {
Log.e(TAG, "onBackPressed");
if(mCustomView!=null){
mFull.onHideCustomView();
}else{
super.onBackPressed();
}
}