intent调用网页就容易了,怎样通过网页标签调用Intent呢?

1先定义 一个接口

 

public abstract interface JSInterface
{
  
public abstract void onLinkClick(String paramString);

  
public abstract void playVideo(String paramString);
}

2 webkit的Activity 应用这接口如:

 

public class ShowWebActivity extends Activity implements JSInterface {

public void onLinkClick(String strUrl) {
  
//todo

}

 
public void playVideo(String strUrl) {

Uri uri 
= Uri.parse(strUrl);

Intent intent 
= new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

}

}

// 3在 index.html里

<a onclick="JSInterface.playVideo('rtsp://192.168.1.80/123.mp4');" > 就会调用playVideo方法的了

 

相关文章:

  • 2022-12-23
  • 2021-12-06
  • 2022-01-12
  • 2022-02-26
  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-15
  • 2022-12-23
  • 2021-10-27
  • 2021-06-07
  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
相关资源
相似解决方案