1.编写java辅助类
public class Helper { /** * js调用后进行跳转 * * @param activity * 传入当前Activity */ public void jump(Activity activity) { Intent mIntent = new Intent(activity, MyActivity.class); activity.startActivity(mIntent); } }
2.然后编写js方法调用java方法
//获取当前Activity var main = plus.android.runtimeMainActivity(); //获取java辅助类 var Helper = plus.android.importClass("com.test.natives.Helper"); //创建对象实例 var mHelper = new Helper(); //调用java中的跳转方法,并且传入当前activity实例 mHelper.jump(main);