我有一个应用程序应该叫一个活动时,一个JavaScript被触发,
这是我的JavaScript至极正在
//的JavaScript接口
私有类JsInterface {
//功能将从资产/ test.js称为
公共无效日志(弦乐味精){
Log.d(味精从JavaScript,味精);
}
这就是我如何调用只需按一个按钮的活动:
按钮旁边=(按钮)findViewById(R.id.button1);
next.setOnClickListener(新View.OnClickListener(){
公共无效的onClick(视图查看){
意图myIntent =新的意图(view.getContext(),VideoVC.class);
startActivityForResult(myIntent,0);
}
});
![Android培训 WebView加强](/d/file/2023/09-17/64396488afe38115d3e5f1b9f9a81e6c.png)
但作为andoid开发IM相当菜鸟无法弄清楚如何改变活动在我JsInterface
我曾在我的JSinterface:
意图myIntent2 =新的意图(JsExampleMain.this,VideoVC.class);
startActivity(myIntent2);
但犯规像startActicity(myIntent2);
如何做到这一点简单的任务?
非常感谢!
解决方案好了,我必须想出办法来! 哈哈是让我发疯了!
所以我不得不将$ C $下在我的日志方法的意图!
//的JavaScript接口
私有类JsInterface {
//功能将从资产/ test.js称为
公共无效日志(弦乐味精){
Log.d(味精从JavaScript,味精);
Log.d(kukusha,mensaje);
意图I =新的意图(JsExampleMain.this,VideoVC.class);
startActivity(ⅰ);
}
}
I have an app that should call an activity when a javaScript is fired,
this is my javascript wich is working
//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);
}
and this is how i call an activity with the touch of a button:
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);
}
});
but as im quite noob on andoid dev cant figure out how to change the activity on my JsInterface
I have tried in my JSinterface:
Intent myIntent2 = new Intent(JsExampleMain.this, VideoVC.class);
startActivity(myIntent2);
but doesnt like the "startActicity(myIntent2);"
how to do this simple task?
thanks a lot!
解决方案ok, so i have figure it out!, haha was making me go crazy!
so i just had to place the code for the Intent inside my log method!
//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);
}
}
相关推荐
最新文章