Wednesday, October 31, 2012

What's New in PhoneGap Android 2.2.0

Well we've tagged Apache Cordova 2.2.0 release candidate 2 which means that Cordova 2.2.0 will be out soon in source release form which will be followed quickly by the binary PhoneGap 2.2.0 release. Shaz wrote up a post on what's new in iOS so I was asked (shamed) to do this on for Android. So without further ado here's what you should expect on Android:

1. FileTransfer API changes

Added support for the onprogress event to get progress events for a FileTransfer operation

We've deprecated the current way that history is handled in Android apps in favour of the default way it is handled in the web view. To go back a page you should be using history.back(). Because of this change iframe's now work properly.

If you need to enable the old way to handle history you can set useBrowserHistory to false in config.xml.

8. Introduce CordovaPlugin class

CordovaPlugin will be replacing the Plugin class for extending PhoneGap functionality. It adds a new execute method public boolean execute(String action, String rawArgs, CallbackContext callbackContext) to enable developers passing large amounts of data to the native side provide their own JSON parser. It also cuts down on boiler-plate, makes multi-threading easier,
and adds an application-wide thread-pool to CordovaInterface. Adds an onReset method that is called when top level navigation changes. This is where you should stop any long running processes like a file transfer that are no longer needed on the new page.

9. Various bug fixes

Back and Menu button events now fire if the cursor is inside a text view.

Fixed a path where the whitelist was not being checked in DroidGap.

FileTransfer.download now supports the trustAllHosts option to allow downloading from servers with self signed certificates.

Removed trailing space from contact.name.formatted.

Properly set contact's IM type.

navigator.language is now set properly when the language is switched in Android settings.

You can still use navigator.network.connection.type as it is being set properly even though it is deprecated. It won't be removed for about 6 months. I'll bring this to Andrews attention though. Thanks for the update.

Is there a fix to the orientation change for android 4.x devices.The activity seems to be reloading on devices > android 4.x ,despite handling orientation changes in manifest and overriding methods in main activity,and my app totally gets refreshed.There seems no native way for me to control it.

Is there anything new that needs to be done to take advantage of the android bridge improvements? Looking through the code it seems like it uses the new options by default by I am still experiencing annoying freezes on ICS.

No, you shouldn't need to do anything. I know that Andrew/Joe and I are trying to figure out the freezes on ICS over on the mailing list. We need a good reproduction scenario to figure this out though.

Hi,Simon. Is there win8 doesn't support Cordova Opendatabase method? I use Cordova 2.2.0 in visual studio express for windows 8 with my project code, when I run, I got error: "javascript runtime error: boject dosen't support property or method openDatabase". So I am wondering the Win8 doesn't support the database in Cordova 2.2.0? Thanks

I'm posting here because there does not seem to be an obvious way of reporting bugs of that kind, not because I want an answer to something (Cordova bug reporting is not so obvious either); to this: "While with an Eclipse local build, the app version in the Android Applications sub-screen is correct, it reports a different, unrelated, and WRONG version with the official PG Build package; for instance our app is actually at "0.9.8" but it shows "1.1" !Yes, widget attributes in config.xml ARE:versionCode = "1"version = "0.9.8",they answered this: "This tracker is for Cordova, not for the Adobe PhoneGap Build service. Please contact them with your issue." So be it. A.R.

I don't think you understand my last post at all: I DID report the bug at https://issues.apache.org/jira/browse/CB-1975They closed it immedialely with the said comment ("This tracker is for Cordova, not for the Adobe PhoneGap Build service. Please contact them with your issue.")The ball is is YOUR camp Simon, weither you like it or not! YOU report it to your brilliant Build dudes at Adobe becaue THEY don't have the heart to have a bug reporting system, that's not my problem anymore! A.R.

Yes, I applied the android:configChanges into my main activity, but without screenSize, because my minimum SDk version is 7. I also had to remove hardware acceleration from the manifest for the same reason.

It sounds like you are doing it wrong. You should always build with the latest SDK in this case API level 17. Then you can set a minimum SDK of 7. This will allow you to have all of those config changes I mentioned in your manifest and you app will work on Android 2.1 or greater.

That is exactly how I do it. But still, this must be a problem in my setup if nobody else has this reload problem. I just have no idea where to look. I am using Sencha Touch 2.1 commercial and phonegap 2.3.0 (also tested with 2.4.0rc1). I basically have the default Sencha-generated app with PhoneGap integration.

I tested my app on v2.2 emulator and reorientation works OK. On my v4.1 HTC one X device it doesn't. Do you think I should create a v4.2 emulator and find a v2.2 device to test... would that reveal something, possibly?

You are missing "screenSize" from the config changes. I guess I wasn't clear about the API level thing. When you target 17 you can have screenSize in the manifest without impacting your ability to run on an API 7 level phone. Try adding it in and seeing if the problem goes away.

I have a simple app which was generated with the latest ST ("sencha generate"), and merged to a newly generated PhoneGap project ("create" in PhoneGap). (BTW, the magic was to have www and android folders side by side at app's root, and then make a symbolic link from android/assets/www point to that www - that way it should be relatively easy to use that same www folder on a possible future iPhone version of the app.)

Anyway, here's how I probably managed to get confused: I had 2.2 as the target SDK at some point (initially, after I generated the skeleton), and I had to edit the manifest to make my app work. Then when I changed the target SDK to v4.2 I undid those changes but apparently forgot to bring back screenSize.

Hi, I appreciate very much the improvements made on html5 video tag support. I spent the last couple of days (and nights) facing problems related to the integration of a video in an Android PhoneGap Application i'm developing. My base platform is Android 4.0.3 and 4.0.4. After finding the correct encoding (webm video) I realized that the video playback result is actually very different from one device to another. In my Asus Transformer (as well as on Samsung Galaxy Note) the video is rendered inline in the phonegap webview (the video is inside the page and has the correct size, set to 320x180 pixels, just for example). The, very excited by this incredible result, I tested my app on another device (Zenithink ZPad C91 tablet) and the video is shown fullscreen... :'( Checking the LogCat I fount this:MediaPlayer error(-38, 0)setScreenOnWhilePlaying(true) is ineffective without a SurfaceHolder

I googled a little bit but I can't figure out what is wrong. Maybe you can give me a clue or can suggest how to fix this problem.

Thank you Simon! It is comforting to know that I was not wrong.. Even if my problem is still there! :)I'll try your VideoPlayer plugin for sure: I read many beatiful comments about it and i'm looking forward to try it! I really hope it will help me with my app! I'll let you know.Thank you very much!

Are you sure that "/data/data/com.suave.nexttrainer/app_database/file_0/0000000001.db" actually exists? If you run "adb shell" then cd to "/data/data/com.suave.nexttrainer/app_database/file_0" do you see the file? You'll have to do that on the emulator if you don't have a rooted phone.