Tuesday, December 18, 2012

What's New in PhoneGap Android 2.3.0

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

1. InAppBrowser – includes events

More details here. In a nutshell, this has the same functionality as the ChildBrowser, and has events support as well. It supports this simplified spec. Also, the InAppBrowser does not use the app whitelist. Example usage:
2. Device API changes

Minor changes as specified here. For Android, device.name is now deprecated for all platforms. For all platforms, there is a new property called device.model which returns what device.name used to return.

3. Various Bug Fixes
  • Searching for emails in Contacts throws an exception always errors out
  • Create script improvement: Display usage and exit when no arguments given
  • Fixed adding a Photo from a HTTPS address to Contact
  • Fixed NPE in onReceivedError with non local errorUrl
  • Camera.getPicture gives error when get a picture from photo library with spaces in its name on Android is now fixed
  • Online/Offline events now fire on subsequent pages of an app
  • fixing cordova commands for paths with spaces in them
  • FileEntry.moveTo across file systems incorrectly calls the success callback

36 comments:

Sindre Haaland said...

What about the bug in getCurrentPosition() on Android 4.0.3 / 4.1.1 ? :(

http://stackoverflow.com/questions/13134356/phonegap-cordova-2-1-geolocation-on-android-is-inconsistent

Simon MacDonald said...

@Sindre Haaland

I'm not seeing a problem with getCurrentPosition() can you provide a reproduction scenario?

Sindre Haaland said...

Sorry, I thought it was the bug the author of that stack overflow post had reported, but it was actually a serverside-bug. I think maybe error_code 1 should be split into two, one error for serverside and one for "file not found" :-)

Anyhow, do you have any suggestions or maybe a blog post on how we can tackle the way Android kills the Phonegap-app when it gets put into the background when fetching an image or taking an image? It only works 1/3 times on my Samsung Galaxy S3 even with all other applications closed ... :/

Simon MacDonald said...

@Sindre Haaland

Well we were working on implementing our own camera functionality so that we did not have to call the Camera Intent in order to take a picture but it is difficult as we are not interested in maintaining our own camera program but it may just come to that.

In the meantime try the Foreground Camera Plugin. It isn't a full featured Camera but it keeps you in the app itself.

https://code.google.com/p/foreground-camera-plugin/

Sindre Haaland said...

Thanks Simon, I will try it out. I read the thread where you decided to let that work go,and I agree with you; phonegap is not in the business of making a camera application for developers,even through it would be awesome for us! :-) Keep up the excellent work!

Cory said...

How about the android bug with the contact field label "work" for the email field.

Simon MacDonald said...

@Cory

If you mean "Saving a contact with an email type of work sets it to home" then yes it is fixed.

yuichi said...

@Simon MacDonald

Any prevision for the release 2.3.0?

Grumpy said...

hi, im trying the foreground-camera-plugin/ but when i press the picture button i get alert in the screen with reason json? Any idea?

Boris Talkfusion said...

How about key "9" problem(keyboard key "9" doesn't work for Android versions 2.2-2.3)?
I just tested PhoneGap Android 2.3.0
and it is not fixed.

Simon MacDonald said...

@Boris Talkfusion

I cannot reproduce this bug. I think the best thing for you to do is to open a bug on JIRA with a reproduction scenario.

https://issues.apache.org/jira/browse/CB

Simon MacDonald said...

@yuichi

Sorry, I don't understand the question.

Simon MacDonald said...

@Grumpy

Not sure as you haven't given me too much info. You should ask developers of the plugin though.

ethought said...

Hi - Any idea whether audio loop functionality has been added for Android devices in this release? Thanks

Simon MacDonald said...

@ethought

Nope, I've been after the guys to review the API inconsistencies for awhile now and it looks like 2.4.0 may be it.

Sam Jacobs said...

I'm a novice to mobile app development. I just wanted to know about the following error "Falling back on PROMPT mode since _cordovaNative is missing" that I get when using Cordova-2.2.0 for my Android application for Gingerbread.The Android sdk is 4.1 and it only works on phones with the latest Android version.

Is there a fix for this or is there something I am missing. Would using the new PhoneGap Android 2.3.0 help?

Simon MacDonald said...

@Sam Jacobs

This is not a problem. In fact there is a bug in Gingerbread Android that we are working around. The log you see tells you that the work around is in effect. Don't worry about it.

doarzevel junk said...

Hi Simon,
I'm looking on ways to add webRTC like RTMP video streaming from a red5 server and was wondering if you have any suggestion on the best way to do it. I would like to have the video decoded on an internal JNI ffmpeg lib, and moved as a raw pixels into a canvas at a specific location (I would like to not have the full screen limitation) - Do you know of a plugin that does something similar ?
(I looked at front-cam-plugin but it looks like it implements a new activity on top of the cordova and is not related to the canvas)
Thanks
DZ

Simon MacDonald said...

@doarzevel junk

No, I don't know of such a plugin. I will honestly tell you that I don't believe your requirement makes sense to be implemented in a PhoneGap app. Depending on what else you need to do you might be better off going full native.

Ademola Olayioye said...

Hello simon,
My phonegap android app has a lot of list on its first page. Now it scrolls well in android 2.3 but when i installed same app on android app- it doesnt scroll well at well at all and it is touch insensitive.
I decided to redesign the app using jquery mobile and wrap with phonegap--thats even worse.
Please help

Simon MacDonald said...

@Ademola Olayioye

I've got a half written blog post on why you shouldn't use jQuery Mobile on a mobile phone but I haven't got a chance to finish it. Long story short, it is too heavy weight for the task.

You may want to try zepto/jqTouch combo instead and I'm hearing good things about qooxdoo as well.

As for scrolling performance, you probably have too many items in your dom.

http://www.html5rocks.com/en/tutorials/speed/scrolling/
https://forum.jquery.com/topic/why-jqm-touchscreen-list-scrolling-performance-stinks-and-what-to-do-about-it

Ademola Olayioye said...

Thank you simon.
The challenge i have is that my app is designed with java(not jqm) and wrapped in phonegap.It works and my list view scrolls well in android 2.3 but it does not in ice cream.
What could be the problem with ice cream.My app is slugissly slow in ice cream but this was not the issue in 2.3.
Your help shall be appreciated.
Please note that i read the links you sent to me and none offered any solution.

Simon MacDonald said...

@Ademola Olayioye

The only other think I can think of and it is counter-intuitive is to disable hardware acceleration in the AndroidManifest.xml.

android:hardwareAccelerated="false"

niranjana devi said...

Hi Simon,

We are facing issue in childbrowser like when i opened the childbrowser for first time,i am getting problem in my local database.I have table in the local database,but i cannot able to insert or retrieve the data.I am getting error as 'no such table exists'.I am getting this problem in android 4.0.x.

We were reported about this bug in phonegap support before two months (in December 2012). They were raised issue in bug report here is the link https://issues.apache.org/jira/browse/CB-2085 . The phonegap support team told us to this particular bug would be fixed in phonegap 2.4.0. But still we are facing this issue in phonegap 2.4.0 InAppBrowser also.

For more details about this bug https://issues.apache.org/jira/browse/CB-2085 . What you think about this bug? Do you know any solution or alternate for this issue? Can you help me on this?

Thanks,
Niran

Simon MacDonald said...

@niranjana devi

I see the issue has been re-opened. I'll talk to Joe about it and if I get some free time I'll look into it myself.

niranjana devi said...

Thank you simon...

Marlon Brenes said...

Hi Simon

one question I am using phonegap 1.7 this older version from 2.0.0 are supported and works well with Android 4.2 jelly bean API 17

because I saw the zxing barcode reader in not working for me in 4.2 in the nexus tablet.

Simon MacDonald said...

@Marlon Brenes

I've got some 4.2 phones and can't reproduce the problem but I don't have a Nexus 7. I know some folks have had some success with Android 4.1 and I'm hoping Android 4.2.2 makes the problem go away for Nexus 7 folks.

Walter Chacón said...

hey Simon,

So, Camera seems not working on any Cordova 2.x, I have tested on 2.2 and 2.4 without any success. The problem happens when Android opens the Camera and the app goes to background, after tapping on ok the app never recovers or never pass to the front. A crash happens saying "java.lang.RuntimeException: Unable to resume activity".

What you suggest ? is this going to be fixed in Cordova 2.5 or any other ? Is this fix coming soon on new versions of Cordova ?

Simon MacDonald said...

@Walter Chacón

Well there are ways to mitigate it but no real way to solve it. I'm recommending people try out the Foreground Camera Plugin for now:

https://code.google.com/p/foreground-camera-plugin/

Prasad Wagh said...

Hi Simon,

Is it possible for me to disable the url location only for the in-app browser.I need the 'Done' button and the navigation buttons but since I want to load a URL that I dont want to show to anyone.

Thanks.

Simon MacDonald said...

@Prasad Wagh

In order to do that you'd need to edit the source code. The other way to do it is to hide the full location bar and use the on location change event in order to close the dialog.

Linson Alfred said...

I'm using Sencha Touch and Phonegap to display a picture recorded with the camera. When taking a picture on an iphone via cordova2.7.0, the picture is drawn with the correct orientation. But using samsung s3, the picture will be leant by -90°(only for portrait images).

navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 25,
destinationType: destinationType.FILE_URI,
targetWidth: 120,
targeHeight: 120,
correctOrientation: true,
sourceType: source });
I use the above code to take picture. The portrait images took from camera displays in correct orientation, issue happens only for the portrait images took from the gallery. Is there is any way to solve this problem?

Simon MacDonald said...

@Linson Alfred

Hey, it could be a bug with the S3, Samsung replaces the general camera app. Take a picture with no width/height options and a quality of 100. Don't even say to correct the orientation. Then transfer the file to your desktop and check to see if it's exif information is set correctly.

murali said...

the bug that the inappbrowser causes the database error 'no such table' still is there even in phonegap 3.0
can anybody help me out to fix this please. this is urgent, thanks.

Simon MacDonald said...

@murali

Comment on the issue:

https://issues.apache.org/jira/browse/CB-2085