3

I have a weird problem. I recently developed an App for ios using Phonegap and Xcode. It went well, they are in the App store, everything worked. One of the elements is a simple email form, written in HTML. It looks like this:

<form name="emailformbtn" id="emailformbtn" onsubmit="submitHandler(e);" action="#emailfromBtn">
                    To: <input type="email" name="emailvarto"/>
                    Message:<textarea cols="40" rows="8" id="emailmessagebtn" name="emailmessage">Email Message</textarea>
                    <input type="button" value="send" onsubmit="submitHandler(e);" onclick="emailProcessfromBtn();"/>
                </form>

Works in ios using Phonegap and Jquery mobile. So i decided to convert the app into Android. Converting all the ObjectiveC into Java, and the rest should work because they are both Phonegap/Cordova.

I am Using Cordova 2.0 and Android 4.1

A lot of it does, but when I try to touch the input of the emails field, it does nothing, and Eclipse displays the message:

The View is not attached to a window. 

Its a Phonegap/Cordova element. I'm not even sure what its trying to say. Is there an issue with Android and Jquery mobile, or does touching input fields in Android using phonegap not invoke native Keyboards?

Any direction or advice on this problem would be greatly appreciated.

Just to make things clearer, even though I followed Phonegap's configuration guide tot he letter, Here is the contents of the Activity.java file:

package uk.co.testdevelopment.testapp.droidapp;

import android.os.Bundle;
import android.view.Menu;
import org.apache.cordova.*;

public class MainActivity extends DroidGap {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.loadUrl("file:///android_asset/www/index.html");
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}
}
Bohdi
  • 1,295
  • 4
  • 28
  • 62

2 Answers2

1

Are you sure your activity is extending 'DroidGap' and not 'Activity'? This definitely sounds wierd and looks more like a problem of the cordova configuration than anything to do with your html

Kiran
  • 5,478
  • 13
  • 56
  • 84
  • Yes I'm extending DroidGap, not Activity. I followed the Phonegap configuration guide to the letter. And within that it told me to edit the activity page in that way. – Bohdi Sep 11 '12 at 14:32
  • public class MainActivity extends DroidGap { – Bohdi Sep 11 '12 at 14:35
  • Well, that makes it complicated. Attaching the view to application happens in setContentView which needs to replaced with some kind of loadUrl call. If they are correct, then the next thing is to make sure the manifest and the cordova xml files are proper. – Kiran Sep 11 '12 at 14:36
  • I have included the full content of my activity file in the original question, not immune to mistakes, but I think its correct and most of the App works. I will review my xml files. – Bohdi Sep 11 '12 at 14:44
  • Another important thing to verify is to make sure the activity tag in manifest is updated with android:configChanges="orientation|keyboardHidden.... as specified in documentation – Kiran Sep 11 '12 at 14:50
  • android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" also done :/ – Bohdi Sep 11 '12 at 14:57
0

The issue appears to be with the menu that you specified that you're calling inflate on. With ICS and higher, the menu is created when the app is first run and not when the menu is accessed. I would recommend removing your menu code to get rid of the View error.

BTW: Views have to be attached to a root element of an Android View, which is normally handled by DroidGap. DroidGap also has menu handlers as well, and you may want to look at using a Menu Plugin or using the CordovaWebView approach to developing a Hybrid App for Android 4.x.

Joe B
  • 596
  • 4
  • 11