本文介绍了如何从PhoneGap的的HTML文件开始ActivityMain的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的js函数

<script type="text/javascript">
            function callNewActivity() {
            window.plugins.StartBarcodeReader.gecis();                   
            }
</script>

这是我StartBar codeReader.java文件

This is my StartBarcodeReader.java file

package com.blogspot.ehamutcu.barcodereader;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
public class StartBarcodeReader extends ActionBarActivity {
    public void gecis(){
                Intent i = new Intent(this,BarcodeReader.class);
                startActivity(i);
    }
}

我想从PhoneGap的的index.html文件启动新的主要活动

I want to start new main activity from phonegap's index.html file

例如,比上开始新的活动中的index.html一按按钮。

For example, One click button on the index.html than start new activity.

我的英文不好:-(,请帮助我。

My english is bad :-( , please help me.

推荐答案

这code访问Android $ C $从科尔多瓦/ PhoneGap的的index.html.Whatç过你写在输入字段上的index.html它然后传递给机器人code和回来到index.html

This code access the android code from cordova/phonegap's index.html.What ever you write in the input field on index.html it will then pass to the android code and came back to the index.html

public class AlertBack extends CordovaPlugin  {
@Override
public boolean execute(String action, JSONArray args,
        CallbackContext callbackContext) throws JSONException {
    if (action.equals("alertBack")) {
       <!-- Here you should write your intent-->        
         Context context = this.cordova.getActivity(); //getting context
           Intent intent = new Intent(context,Yourclass.class); //mention your activity in manifest
            context.startActivity(intent);//start activity
       <!-- Intent end -->
         Toast.makeText(cordova.getActivity(), "Using Toast You Entered "+
         args.getString(0), Toast.LENGTH_LONG).show();
        callbackContext.success("Returning from native You Entered "
                + args.getString(0));
        return true;
    }
    return false; // Returning false results in a "MethodNotFound" error.
}

}

我上传一个工作example.You可以下载并测试它。链接。如果你仍然面临着无任何troubles.Feel评论:)

I am uploading a working example.You can download and test it.link.If you still face any troubles.Feel free to comment :)

这篇关于如何从PhoneGap的的HTML文件开始ActivityMain的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 05:47