How to implement phonegap/cordova in android webview?

359 views
Skip to first unread message

Alex Stanese

unread,
Jul 11, 2014, 5:33:44 AM7/11/14
to phon...@googlegroups.com

I need just a few minutes for someone to tell me if these steps are correct for implementing cordova in a android webview:

1) I create project: cordova create hello com.example.hello HelloWorld

2) cordova run android (cordova.jar is created) => the app is launched => cordova is ready si shown

3) I create a main.xml with this code:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<org.apache.cordova.CordovaWebView 
android:id="@+id/tutorialView" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_weight="1" /> 


</LinearLayout>

4)I modify the main java file to be like this:

public class CordovaViewTestActivity extends Activity implements CordovaInterface {
Private final ExecutorService threadPool =Executors.newCachedThreadPool ()
    CordovaWebView cwv;
    /* Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        cwv = (CordovaWebView) findViewById(R.id.tutorialView);
        Config.init(this);
        cwv.loadUrl(Config.getStartUrl());
    }
@Override
public ExecutorService getThreadPool() {
    return threadPool;
}

5) and when I run I get: unfortunately helloworld has stopped. These steps are taken from the cordova site:http://docs.phonegap.com/en/3.3.0/guide_platforms_android_webview.md.html#Android%20WebViews

Please help!

jcesarmobile

unread,
Jul 11, 2014, 5:47:47 AM7/11/14
to phon...@googlegroups.com
Maybe this can help you, is for embedding a cordova webview in an android fragment

https://github.com/Adobe-Marketing-Cloud/app-sample-android-phonegap/wiki/Embed-Webview-in-Android-Fragment
Reply all
Reply to author
Forward
0 new messages