Back-porting from Android 2.0 to Android 1.5

by AJ » Tue, 08 Dec 2009 07:06:23 GMT


Sponsored Links
 I have read the website and archives on backporting (building on SDK
2.0 to run on SDK 1.5) and it seems consensus is to change the minimum
SDK version required in the manifest (from 5 back to 3) and check for
any private API calls. I've done that, but I have two remaining
concerns. [Note: I wrote/built this app on 2.0 with emulators without
access to an Android 1.5 device.]

1) drawable verses the new drawable-* ... if I don't have an icon in
drawable.png will my application be icon-less in 1.5? Do I need to
copy one of the new icons in there? If so, which one?

2) search ... how does the "SEARCH" activity get raised for an
application on SDK 1.5 devices (which don't appear to have a hardware
search button.) Do I need to add a menu option and raise SEARCH as a
sub-activity? [Note: I am 100% confused by search button on all
android versions 'cos what I read says SDK 2.0 copes with virtual
buttons, yet those devices (in emulator) seem to have hardware ones.
What am I missing?]

Thanks in advance for help with these. Please let me know if there are
any more issues I am missing.

--



Back-porting from Android 2.0 to Android 1.5

by Dianne Hackborn » Tue, 08 Dec 2009 07:26:30 GMT


 



If you want to run on pre-1.6 platforms, I would suggest putting your medium
density bitmaps in drawable/* instead of drawable-mdpi/*.  1.6 and later
will assume that these are medium density.



Whether or not there is a search button is really a device thing, and not a
platform version thing.  For example, the G1 has a search key on its hard
keyboard, and you can assume there will be devices running 2.0 and later
that don't have a search key.  If search is important for your app, you will
want to have another mechanism to get to it -- often a menu item.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--


Sponsored Links


Back-porting from Android 2.0 to Android 1.5

by theSmith » Wed, 09 Dec 2009 00:20:59 GMT


 Should we just create our own search activity or is there one
available in 1.5?  As far as I know the global search feature is only
1.6+.

When creating our own activity, how would we capture the search key
(hard) being pressed on a device?

-Chris






--



Back-porting from Android 2.0 to Android 1.5

by AJ » Thu, 10 Dec 2009 17:10:34 GMT


 n Dec 7, 4:25pm, Dianne Hackborn <hack...@android.com> wrote:
Thank you.


Thanks, again, that helped a lot. I've added a menu option (although
I'd love to know how to hide that if I could detect a hardware
button.)

My remaining problem is the search suggestion provider code (which I
took from a 2.0 sample) will compile on SDK 1.5 (I've built a SDK
project to ensure little is hidden by backwards compatibility.)
Anyway, things seem good unless I actually return search suggestions
via a

/**
* The columns we'll include in our search suggestions. There are
others that could be used
* to further customize the suggestions, see the docs in {...@link
SearchManager} for the details
* on additional columns that are supported.
*/
private static final String[] COLUMNS = {
"_id", // must include this column
SearchManager.SUGGEST_COLUMN_TEXT_1,
SearchManager.SUGGEST_COLUMN_INTENT_DATA,
};

The generation is here:

MatrixCursor cursor = new MatrixCursor(COLUMNS, 0);
for (String ingredient : matching_ingredients) {
cursor.addRow(new String[] {
ingredient, // _id
ingredient, // text1
ingredient // intent_data (included when
clicking
on item)
});
}


I've tried reading SearchManager documentation, but cannot seem to
track down what columns it is expecting (or not expecting) for SDK 1.5
that causes it to try to get a long when I don't have one.


Unless I comment that out, I get:

12-08 12:02:21.263: ERROR/AndroidRuntime(808):
java.lang.NumberFormatException: Achee
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
java.lang.Long.parse(Long.java:368)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
java.lang.Long.parseLong(Long.java:358)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
java.lang.Long.parseLong(Long.java:323)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
java.lang.Long.valueOf(Long.java:570)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
android.database.MatrixCursor.getLong(MatrixCursor.java:245)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
android.database.CursorWrapper.getLong(CursorWrapper.java:127)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
android.widget.CursorAdapter.getItemId(CursorAdapter.java:156)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
android.widget.AutoCompleteTextView.buildDropDown
(AutoCompleteTextView.java:900)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
android.widget.AutoCompleteTextView.showDropDown
(AutoCompleteTextView.java:843)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
android.widget.AutoCompleteTextView.onFilterComplete
(AutoCompleteTextView.java:749)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
android.widget.Filter$ResultsHandler.handleMessage(Filter.java:266)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
android.os.Handler.dispatchMessage(Handler.java:99)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
android.os.Looper.loop(Looper.java:123)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
android.app.ActivityThread.main(ActivityThread.java:3948)
12-08 12:02:21.263: ERROR/AndroidRuntime(808): at
java.lang.reflect.Method.invokeNative(Native Method)
12-08 12:02:21.263: ERROR/AndroidRuntime



Back-porting from Android 2.0 to Android 1.5

by theSmith » Wed, 16 Dec 2009 14:20:14 GMT


 Diane

My mistake, since I started developing when 1.6 was released I thought
the search manager was the new QSB from 1.6

@AJ

My app is crashing too because of the QSR terms in the searchable.xml
The problem then becomes how can you access them from 1.6+ without
them being seen in 1.5?

On Dec 8, 2:13pm, AJ <adam.j...@gmail.com> wrote:

--



Other Threads

1. Google Data APIs Client Libraries

Has anyone had success using Google Data APIs Client Libraries. I
can seem to successfully use the GData Java client libraries in an
Android app. I notice that there used to be some GData access classes
in the Wireless packages that have been removed. Should I be using
some map data classes in the com.google.android.maps classes I not
seeing? I started to go down the path of accessing data through raw
http calls, but it a beating.

Any advice would be much appreciated.

Thanks,

Patrick
--~--~---------~--~----~------------~-------~--~----~

2. compatibility of an app across android versions

> if an application is developed entirely on SDK 1.1, would it run (with

Run, yes. And there is a very good chance that it will look fine as well.

That being said, I highly recommend you test using a 1.5 emulator, on a
1.5 image, just to be sure.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!



--~--~---------~--~----~------------~-------~--~----~

3. compatibility of an app across android versions

4. Cursor for service component?

5. How to tell when application exits?

6. Manipulating WebKit Form-Data

7. Phone matrix