Change activity using javaScript in Android

I have an application that should trigger an action when javaScript starts,

this is my javascript that works

// 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 so I call the action a click 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 how im completely noob on andoid dev can not figure out how to change activity on my JsInterface

I tried in my JSinterface:

 Intent myIntent2 = new Intent(JsExampleMain.this, VideoVC.class); startActivity(myIntent2); 

but don't like "startActicity (myIntent2);"

How to complete this simple task?

Many thanks!

+4
source share
1 answer

ok, so I figured it out !, Haha made me go crazy!

so I just had to put the code for 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); } } 
+2
source

Source: https://habr.com/ru/post/1400142/


All Articles