更改活动的JavaScript Android中 [英] change activity with javaScript in Android

查看:108
本文介绍了更改活动的JavaScript Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序应该叫一个活动时,一个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);
        }
    });
 

但作为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); 
    }
 }

这篇关于更改活动的JavaScript Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆