man*_*urt 5 javascript android android-activity
我有一个应用程序应该在触发 JavaScript 时调用一个活动,
这是我的 JavaScript 正在运行
javascript接口
private class JsInterface{
//function that will be called from assets/test.js
public void log(String msg){
Log.d("MSG FROM JAVASCRIPT", msg);
}
Run Code Online (Sandbox Code Playgroud)
这就是我通过按一下按钮来调用活动的方式:
Button next = (Button) findViewById(R.id.button1);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), VideoVC.class);
startActivityForResult(myIntent, 0);
}
});
Run Code Online (Sandbox Code Playgroud)
但是由于我对 Android 开发人员很菜鸟无法弄清楚如何更改我的 JsInterface 上的活动
我在我的 JSinterface 中尝试过:
Intent myIntent2 = new Intent(JsExampleMain.this, VideoVC.class);
startActivity(myIntent2);
Run Code Online (Sandbox Code Playgroud)
但不喜欢“startActicity(myIntent2);”
如何完成这个简单的任务?
好吧,我已经弄清楚了!,哈哈,让我发疯了!
所以我只需将意图的代码放在我的日志方法中!
Run Code Online (Sandbox Code Playgroud)//javascript interface private class JsInterface{ //function that will be called from assets/test.js public void log(String msg){ Log.d("MSG FROM JAVASCRIPT", msg); Log.d("kukusha", "mensaje"); Intent i = new Intent(JsExampleMain.this,VideoVC.class); startActivity(i); } }
| 归档时间: |
|
| 查看次数: |
1531 次 |
| 最近记录: |