reset password
Author Message
ptran6
Posts: 25
Posted 16:36 Feb 19, 2012 |

Hey Mahan,

My Lab3 app works perfectly on the Android 2.2 emulator, but it doesn't seem to work on the 4.0.3 emulator. So I was wondering, is there a specific emulator OS version you will be using to test our lab assignments?

Thanks.

- Peter

mhajianpour
Posts: 20
Posted 23:58 Feb 19, 2012 |

Hi Peter,

I can tell which version you used by looking at your manifest. I will be running your APK to test it on a device.

I am wondering what part of it doesn't work on 4.x. Any specific issues?

--

Mahan Hajianpour

ptran6
Posts: 25
Posted 14:05 Feb 20, 2012 |

Hi Mahan, on the 4.0.3 emulator, the app doesn't display any bookmarks (the ListView is empty), even though there are bookmarks in the browser. I tried adding a new bookmark from within the app, but the ListView is still empty. I can see the new bookmark from the browser though. Any ideas?

mhajianpour
Posts: 20
Posted 14:06 Feb 20, 2012 |

That is strange. I am running a version and it works fine in 4.0.3. What's the URI you're using?

ptran6
Posts: 25
Posted 16:23 Feb 20, 2012 |

Actually, I just figured out the problem. The bookmarks table contains both bookmarks and history records, so I use the selection clause to get only bookmarks (i.e. records where the "bookmark" column = 1). This is my original code:

 

String[] projection = { 
 
    Browser.BookmarkColumns._ID, 
    Browser.BookmarkColumns.TITLE, 
    Browser.BookmarkColumns.URL };
String selectionClause = Browser.BookmarkColumns.BOOKMARK + " = ?";
String[] selectionArgs = { "1" };
String sortOrder = null;
 
Cursor cursor = this.getContentResolver().query(
    Browser.BOOKMARKS_URI, projection,
    selectionClause, selectionArgs, sortOrder );

 

This doesn't work on 4.0.3. However, the following does work:

 

...
String selectionClause = Browser.BookmarkColumns.BOOKMARK + " = 1";
String[] selectionArgs = null;  // { "1" };
...

 

So it looks like a problem with the selection arguments. Nevertheless, I noticed something else. On 2.2, the ListView automatically updates upon insert/update/delete without having to manually reset the adapter, but on 4.0.3 you need to manually re-query the ContentProvider and reset the adapter. Also, updating bookmarks works on 2.2, but the same code doesn't work on 4.0.3 for some reason, even after I took into account the selection args "problem".