我在这里:
package com.orb.tvdroid;
import android.app.Activity;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
/**
* Created by Igor Lima on 29/06/2017.
*/
public class TVDroid extends AppCompatActivity {
WebView TVDroid;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tv_droid);
final Activity activity = this;
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.mipmap.ic_launcher);
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#007f00")));
Toast.makeText(getApplicationContext(), "Espere o carregamento da página completar.", Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "Em seguida, escolha um dos canais disponíveis para começar a transmissão.", Toast.LENGTH_LONG).show();
final String link = this.getIntent().getStringExtra("Link");
TVDroid = (WebView) findViewById(R.id.TVdroid);
this.registerForContextMenu(TVDroid);
WebSettings webSettings = TVDroid.getSettings();
webSettings.setJavaScriptEnabled(true);
TVDroid.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progresso) {
activity.setTitle("TVDroid... " + progresso + "%");
activity.setProgress(progresso * 100);
if (progresso == 100)
activity.setTitle("TVDroid");
}
});
TVDroid.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return true;
}
});
TVDroid.loadUrl(link);
}
}
我已经在这里研究了很多解决方案,但是其中许多解决方案似乎对我想做的事情有点太多了。我不想要一个完整的视频播放器功能,我想要的只是能够双击视频播放器并在我的应用程序上全屏设置。
提前致谢。
刚刚做过这些人,感谢Vishal的想法,这是最后的onCreate:
WebView TVDroid;
ProgressDialog carregando;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fullscreen);
this.setTitle("TVDroid");
carregando = new ProgressDialog(TVDroid.this);
carregando.show();
mVisible = true;
mControlsView = findViewById(R.id.fullscreen_content_controls);
mContentView = findViewById(R.id.fullscreen_content);
mContentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
toggle();
}
});
final Activity activity = this;
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.mipmap.ic_launcher);
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#007f00")));
Toast.makeText(getApplicationContext(), "Espere o carregamento da página completar.", Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "Em seguida, escolha um dos canais disponíveis para começar a transmissão.", Toast.LENGTH_LONG).show();
final String link = this.getIntent().getStringExtra("Link");
TVDroid = (WebView) findViewById(R.id.TVdroid);
TVDroid.getSettings().setJavaScriptEnabled(true);
TVDroid.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
TVDroid.loadUrl("javascript:(function() { " +
"var head = document.getElementsByTagName('header')[0];"
+ "head.parentNode.removeChild(head);" +
"})()");
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return true;
}
});
TVDroid.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progresso) {
carregando.setMessage("Carregando página: " + progresso + "%");
activity.setProgress(progresso * 100);
if (progresso == 100)
carregando.dismiss();
}
});
TVDroid.loadUrl(link);
}
答案 0 :(得分:0)
试试这个 -
创建一个新的FullscreenActivity -
File -> New -> Activity -> FullscreenActivity
将您的TVDroid
活动代码复制到FullscreenActivity
。