Android开发,JS调后台java代码,创建videoView,页面没反应,请问这是为什么? Android开发,前台WebView中的JS调后台java代码,代码中实例化videoView,start方法也执行了,requestFocus方法也执行了,多线程也实现了,程序执行无错误,但页面没有跳转,请问这可能是什么问题?Android开发JSvideoView 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 @Override public void onCommonCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.business_layout_dzdd_spcx_vedio); //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);// 竖屏 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//横屏 VideoView videoView = (VideoView)findViewById(R.id.videoView1); //String e = "http://vipimage.sunday-mobi.com/2013/4/b3ed9fde-eedf-4c71-8dbd-e97acc5237f5.flv"; //String path = "http://vipimage.sunday-mobi.com/2013/4/2945920e-48ac-46ae-afb6-f0c1adae2b2f.mp4"; videoView.setVideoPath(vedioUrl); //vedioUrl是视频地址 videoView.setMediaController(new MediaController(this)); }这样你试试看 全屏播放 页面也贴给你<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/CommonLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/Layout_B" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="center" > <VideoView android:layout_height="match_parent" android:id="@+id/videoView1" android:layout_width="match_parent"> </VideoView> </LinearLayout></LinearLayout>很简单的 这是我的代码,请帮忙看看是啥问题。前台:function showVideo() { return window.sv.play();}后台:private Handler handler=null;protected void onCreate(Bundle savedInstanceState) { handler = new Handler(); webview.addJavascriptInterface(new ShowVideo(), "sv");}class ShowVideo{ public void play(){ try{ Thread t = new Thread() { public void run() { handler.post(runnableUi); } }; t.start(); }catch(Exception e){ System.out.println(e.getMessage()); } }}//构建Runnable对象Runnable runnableUi=new Runnable(){ @Override public void run() { videoView = (VideoView) findViewById(R.id.VideoView1); videoView.setVideoURI(Uri.parse("file:///sdcard/MyFirstAppMovie/aaa.mp4")); videoView.setMediaController(new MediaController(MainActivity.this)); videoView.start(); videoView.requestFocus(); } }; Android中怎么查看native方法的定义 intent取值问题 js代码可以关掉手机浏览器 如何获得电池相关信息 毕设想做个android手机软件 求帮助 求助:WebView和JS的问题 基于Gcridview的一个简单应用调试错了(还有如何从LogCat中找错) 安卓程序,访问网络时路径正确,但是却得不到资源 android intent传递int型数据 AS 3.0如何彻底解决aapt2错误 有人做过安卓广告sdk开发吗? 和服务端交互用什么技术比较好?
public void onCommonCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.business_layout_dzdd_spcx_vedio);
//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);// 竖屏
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//横屏
VideoView videoView = (VideoView)findViewById(R.id.videoView1);
//String e = "http://vipimage.sunday-mobi.com/2013/4/b3ed9fde-eedf-4c71-8dbd-e97acc5237f5.flv";
//String path = "http://vipimage.sunday-mobi.com/2013/4/2945920e-48ac-46ae-afb6-f0c1adae2b2f.mp4";
videoView.setVideoPath(vedioUrl); //vedioUrl是视频地址
videoView.setMediaController(new MediaController(this));
}这样你试试看 全屏播放 页面也贴给你
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/CommonLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/Layout_B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
>
<VideoView
android:layout_height="match_parent"
android:id="@+id/videoView1"
android:layout_width="match_parent">
</VideoView>
</LinearLayout>
</LinearLayout>很简单的
function showVideo()
{
return window.sv.play();
}
后台:
private Handler handler=null;protected void onCreate(Bundle savedInstanceState) {
handler = new Handler();
webview.addJavascriptInterface(new ShowVideo(), "sv");
}
class ShowVideo{
public void play(){
try{
Thread t = new Thread() {
public void run() {
handler.post(runnableUi);
}
};
t.start();
}catch(Exception e){
System.out.println(e.getMessage());
}
}
}
//构建Runnable对象
Runnable runnableUi=new Runnable(){
@Override
public void run() {
videoView = (VideoView) findViewById(R.id.VideoView1);
videoView.setVideoURI(Uri.parse("file:///sdcard/MyFirstAppMovie/aaa.mp4"));
videoView.setMediaController(new MediaController(MainActivity.this));
videoView.start();
videoView.requestFocus();
}
};