Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding Cordova WebView on Android

Tags:

cordova

i'm using phonegap "2.0" with Android SDK 15, i just want to Embedding Cordova WebView on Android prject, i used step by step the guide Links, also another example in github Links my app crashed and stoped automatically when I run. Logcat error :

android.view.InflateException: Binary XML file line #6: Error inflating class org.apache.cordova.CordovaWebView

my xml file "main.xml":

<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent">
    <org.apache.cordova.CordovaWebView android:id="@+id/phoneGapView" android:layout_width="fill_parent" android:layout_height="fill_parent" />
</LinearLayout >

Thx in advance.. :)

like image 354
salimido Avatar asked Dec 01 '22 05:12

salimido


1 Answers

You may have the same error as I did. Once I implemented the methods derived from CordovaInterface in my activity, in particular the getActivity method, the application started just fine.

@Override
public Activity getActivity() {
  return this;
}

Note that the default implementation returns null while the CordovaWebView most likely requires a proper Activity instance for its initialization.

Note: I am using PhoneGap 2.1.0

like image 92
DonSteep Avatar answered Dec 06 '22 11:12

DonSteep