[android-developers] Re: Picking up a PhoneBook entry under Android 2.0 !!!

2010-01-27 Thread Mike Olson
I know this is a bit of an old thread, but I implemented the
workaround above to get my 1.5 emulator to launch and now my code
crashes when I try to run it in the 1.5 emulator. The error is an
InvocationTargetException with a cause of VerifyError. I'm currently
searching for answers on the web but I'm not finding anything. Any
ideas?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Picking up a PhoneBook entry under Android 2.0 !!!

2010-01-27 Thread Mike Olson
I figured it out from a combination of the info on these two pages:
http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/1/
http://android-developers.blogspot.com/2009/04/backward-compatibility-for-android.html

I needed to write an abstract wrapper class that generates a concrete
class depending on the SDK version. Then I had to implement different
concrete classes for each set of code I needed and generate them on
the fly depending on the SDK version. Weird stuff!

PS. I know it's likely that the people on this thread knew that
already or didn't need to know it, but I'm posting this to help anyone
who may find this thread on Google.

On Jan 27, 8:17 am, Mike Olson mish.ol...@gmail.com wrote:
 I know this is a bit of an old thread, but I implemented the
 workaround above to get my 1.5 emulator to launch and now my code
 crashes when I try to run it in the 1.5 emulator. The error is an
 InvocationTargetException with a cause of VerifyError. I'm currently
 searching for answers on the web but I'm not finding anything. Any
 ideas?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Picking up a PhoneBook entry under Android 2.0 !!!

2009-12-02 Thread Dave Rowntree


On Nov 22, 11:40 am, GDroid baron...@gmail.com wrote:
 Using this solution, I need to set your API Target Level to 5
 (Android2.0), and set the minimum (android:minSdkVersion) to 3
 (Android1.5). This way I am able to compile code which reference API
 5 methods and run on older devices.
 However, there is a major problem with that. I can't run or debug this
 code on older devices (2.0) using the Eclipse plug-in.
 Anyone having the same problem?

The problem you are seeing does have (at least one) workaround.
You need to do two things:
1. Change the Deployment Target Selection Mode for each Launch
Configuration of interest.
Go into the Run Configurations (Run|Run Configurations), select each
Android Application you want to be able to run on older SDK versions
in turn, and on the Target Tab for each, change the Deployment Target
Selection Mode to Manual. Apply the changes and close the window.
2. Manually launch the AVD(s) you want to run/debug against.

That's it.
When you run/debug your app now you will be offered a selection of
running AVDs to run your app against.
HTH
(it works for me g)

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Picking up a PhoneBook entry under Android 2.0 !!!

2009-11-29 Thread frantz lohier
Thank you Dmitri for the code. I've reviewed it and don't see any
interaction with the AccountManager.

One of the problem with SDK 2.0 is that pickup contacts is condition by
having a user login with a proper account.

My application crashes under the emulator because I cannot profile a Gmail
account for instance from which to browse  the phonebook.

There seem to be a new AccountManager APIs. Can you or anybody highlight how
this API works. For instance, when Starting an activity to pick up a
contact, an app would want to make sure that the user has picked up an
account and logged to it (if not, defaulting to the SIm contact list seems
appropriate).

Would it be possible for you to update your very good businesscardacitivity
to reflect this ?

Thanks,





On Tue, Nov 3, 2009 at 1:44 PM, Dmitri Plotnikov dplotni...@google.comwrote:

 I just published some sample code illustrating this use of both legacy and
 new Contacts APIs in the same app.  See
 http://code.google.com/p/android-business-card

 Cheers,
 - Dmitri


 On Mon, Nov 2, 2009 at 9:31 AM, Mark Murphy mmur...@commonsware.comwrote:

 jarkman wrote:
  int sdkVersion = Integer.parseInt(Build.VERSION.SDK);

 Note that if you are using API version 4 (1.6 and newer), there is
 Build.VERSION.SDK_INT, which already converts this to an integer.

 If you are still using API version 3, you'll need to parse the String as
 shown above.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com | http://twitter.com/commonsguy

 Android 1.6 Programming Books: http://commonsware.com/books

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: Picking up a PhoneBook entry under Android 2.0 !!!

2009-11-29 Thread frantz lohier
Thanks Jarkman.

2 questions:

1) Does:
int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
if (sdkVersion  Build.VERSION_CODES.ECLAIR)

Return the OS/SDK version currently run by the underlying platform or does
it return the target SDK level the APP was compiled for ?

2) Is there a way for an App to learn what is the current language
(input/display)  being used ?

Thanks,


On Mon, Nov 2, 2009 at 9:23 AM, jarkman jark...@gmail.com wrote:



 On Nov 2, 5:02 pm, frantz lohier floh...@gmail.com wrote:


   + in the Market, should we upload different app versions compiled for
  different SDK/OS configuration ? Can the market app offer a specific
 version
  of an app to an end-user depending on what OS version is used ?

 It would certainly make our lives easier if the Market supported
 alternative binaries for different OS versions.

   + how does an app know what OS version is currently used ?
   + how can an app dynamically make use of new SDK feature with the same
  executable ? (for example, how can I activate TTS if it is supported).
  Backward compatibility is discussed here:
 http://android-developers.blogspot.com/2009/04/backward-compatibility
  Unfortunatly, this link does not tell me how to selectively do an import
  android.speech.tts.TextToSpeech for my code to compile.

 What you can do is build against the 2.0 SDK, but wrap up all your 2.0
 stuff in a class which you only instantiate if you are on a 2.0
 device.
 Build a base class which is mostly abstract, and a 1.6 version of the
 same class which implements the same functionality but with 1.6 APIs.
 Then use this trick to instantiate the right subclass:

 int sdkVersion = Integer.parseInt(Build.VERSION.SDK);
 if (sdkVersion  Build.VERSION_CODES.ECLAIR)
 {
  className = com.foo.ContactAccessorSdk3_4;   // one subclass of
 ContactAccessorBase
 }
 else
 {
  className = com.foo.ContactAccessorSdk5; // another subclass of
 ContactAccessorBase
 }

  /*
  * Find the required class by name and instantiate it.
  */
  try {
 Class? extends ContactAccessor clazz =
Class.forName(className).asSubclass
 (ContactAccessor.class);
ContactAccessorBase sInstance = clazz.newInstance();
  } catch (Exception e) {
  throw new IllegalStateException(e);
 }

 (thanks, Dmitri!)




  On Mon, Nov 2, 2009 at 8:54 AM, frantz lohier floh...@gmail.com wrote:
   Thanks Jarkman for your perspectives on this.
 
   2 additional questions;
 
   - can the emulator simulate accessing a gmail account ? (as ways to
 avoid
   dealing with the Accountmanager APIs)
 
   - A more general and critical question; if apps start to have to behave
   differently based on the Android OS version they run on, there are a
 lot of
   implications;
 
   On Mon, Nov 2, 2009 at 2:33 AM, jarkman jark...@gmail.com wrote:
 
   On Nov 2, 1:57 am, frantz lohier floh...@gmail.com wrote:
 
When running the same code (compiled with SDK 1.6) and a target
 emulator
   at
2.0 level, the above code never return the entries I have populated
 in
   my
the phone book. It's as if the phonebook was always empty.
 
   My (hazy) understanding is that the 1.6 APIs will only show you the
   contacts in the primary gmail-syncing account on the device. As the
   emulator doesn't have one of those accounts, your newly-entered
   contacts are in a different account (or in some kind of no-account
   limbo), so they are invisible to the 1.6 APIs.
 
   I think that on a real device with a real account the situation will
   be better, though you still need to move to the 2.0 APIs to support
   users who have multiple accounts.
 
   It may be possible to use the AccountManager APIs to manufacture an
   account of the right sort in the emulator, which would make it
   possible to enter new contacts who would show up in the 1.6 APIs, but
   I don't think there are enough clues in the published docs to tell us
   how to do that.
 
- When running the emulator in 2.0 mode, the default local input
 type is
Japaneese. Any way to change this ?
 
   Yes, you can fiddle with the IME settings in the Settings app, in
   'Language  Keyboard'.
 
   Richard
 
   --
   You received this message because you are subscribed to the Google
   Groups Android Developers group.
   To post to this group, send email to
 android-developers@googlegroups.com
   To unsubscribe from this group, send email to
   android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com
 
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en
 
 

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 

[android-developers] Re: Picking up a PhoneBook entry under Android 2.0 !!!

2009-11-22 Thread GDroid
I've tested this code as well and it is indeed backward.

Using this solution, I need to set your API Target Level to 5
(Android 2.0), and set the minimum (android:minSdkVersion) to 3
(Android 1.5). This way I am able to compile code which reference API
5 methods and run on older devices.
However, there is a major problem with that. I can't run or debug this
code on older devices (2.0) using the Eclipse plug-in.
Anyone having the same problem?

This makes testing and debugging applications on older devices
difficult. Aren't we doing all the extra work for the application to
run on the older platforms??

Anyway, I think I have a solution (and I would like to get feedback
from google guys as well):

- Create a new Java Project
- Add the ..platforms\android-2.0\Android.Jar to the Libraries.
- Write your 2.0 code in this project.
- In your main project, reference the new project.
- Now you can compile, run and Debug on all devices.


* Whatever design pattern you choose for the loading of the new code
- Don't forget to instantiate the classes by name (as in the examples
above).

Any other ideas?



On Nov 20, 6:46 pm, stanlick stanl...@gmail.com wrote:
 Thanks Dmitri --

 Is this test correct?

             int sdkVersion = Integer.parseInt
 (Build.VERSION.SDK);       // Cupcake style
             if (sdkVersion = Build.VERSION_CODES.ECLAIR) {
                 className = ...ContactAccessorSdk3_4;
             } else {
                 className = ...ContactAccessorSdk5;
             }
 It looks backward?

 Peace,
 Scott

 On Nov 3, 3:44 pm, Dmitri Plotnikov dplotni...@google.com wrote:



  I just published some sample code illustrating this use of both legacy and
  new Contacts APIs in the same app.  
  Seehttp://code.google.com/p/android-business-card

  Cheers,
  - Dmitri

  On Mon, Nov 2, 2009 at 9:31 AM, Mark Murphy mmur...@commonsware.com wrote:
   jarkman wrote:
int sdkVersion = Integer.parseInt(Build.VERSION.SDK);

   Note that if you are using API version 4 (1.6 and newer), there is
   Build.VERSION.SDK_INT, which already converts this to an integer.

   If you are still using API version 3, you'll need to parse the String as
   shown above.

   --
   Mark Murphy (a Commons Guy)
  http://commonsware.com|http://twitter.com/commonsguy

   Android 1.6 Programming Books:http://commonsware.com/books

   --
   You received this message because you are subscribed to the Google
   Groups Android Developers group.
   To post to this group, send email to android-developers@googlegroups.com
   To unsubscribe from this group, send email to
   android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs
cr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Picking up a PhoneBook entry under Android 2.0 !!!

2009-11-20 Thread stanlick
Thanks Dmitri --

Is this test correct?

int sdkVersion = Integer.parseInt
(Build.VERSION.SDK);   // Cupcake style
if (sdkVersion = Build.VERSION_CODES.ECLAIR) {
className = ...ContactAccessorSdk3_4;
} else {
className = ...ContactAccessorSdk5;
}
It looks backward?

Peace,
Scott

On Nov 3, 3:44 pm, Dmitri Plotnikov dplotni...@google.com wrote:
 I just published some sample code illustrating this use of both legacy and
 new Contacts APIs in the same app.  
 Seehttp://code.google.com/p/android-business-card

 Cheers,
 - Dmitri

 On Mon, Nov 2, 2009 at 9:31 AM, Mark Murphy mmur...@commonsware.com wrote:
  jarkman wrote:
   int sdkVersion = Integer.parseInt(Build.VERSION.SDK);

  Note that if you are using API version 4 (1.6 and newer), there is
  Build.VERSION.SDK_INT, which already converts this to an integer.

  If you are still using API version 3, you'll need to parse the String as
  shown above.

  --
  Mark Murphy (a Commons Guy)
 http://commonsware.com|http://twitter.com/commonsguy

  Android 1.6 Programming Books:http://commonsware.com/books

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Picking up a PhoneBook entry under Android 2.0 !!!

2009-11-03 Thread Dmitri Plotnikov
I just published some sample code illustrating this use of both legacy and
new Contacts APIs in the same app.  See
http://code.google.com/p/android-business-card

Cheers,
- Dmitri

On Mon, Nov 2, 2009 at 9:31 AM, Mark Murphy mmur...@commonsware.com wrote:

 jarkman wrote:
  int sdkVersion = Integer.parseInt(Build.VERSION.SDK);

 Note that if you are using API version 4 (1.6 and newer), there is
 Build.VERSION.SDK_INT, which already converts this to an integer.

 If you are still using API version 3, you'll need to parse the String as
 shown above.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com | http://twitter.com/commonsguy

 Android 1.6 Programming Books: http://commonsware.com/books

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Picking up a PhoneBook entry under Android 2.0 !!!

2009-11-02 Thread jarkman


On Nov 2, 1:57 am, frantz lohier floh...@gmail.com wrote:

 When running the same code (compiled with SDK 1.6) and a target emulator at
 2.0 level, the above code never return the entries I have populated in my
 the phone book. It's as if the phonebook was always empty.

My (hazy) understanding is that the 1.6 APIs will only show you the
contacts in the primary gmail-syncing account on the device. As the
emulator doesn't have one of those accounts, your newly-entered
contacts are in a different account (or in some kind of no-account
limbo), so they are invisible to the 1.6 APIs.

I think that on a real device with a real account the situation will
be better, though you still need to move to the 2.0 APIs to support
users who have multiple accounts.

It may be possible to use the AccountManager APIs to manufacture an
account of the right sort in the emulator, which would make it
possible to enter new contacts who would show up in the 1.6 APIs, but
I don't think there are enough clues in the published docs to tell us
how to do that.

 - When running the emulator in 2.0 mode, the default local input type is
 Japaneese. Any way to change this ?

Yes, you can fiddle with the IME settings in the Settings app, in
'Language  Keyboard'.

Richard

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en