Suppoting android 1.6. VerifyError.

by Kirill » Fri, 18 Mar 2011 21:17:44 GMT


Sponsored Links
 I've got a method like this one. I want to autocomplite e-mail in
EditText. But application crashes

private void setAccount() {
        Account[] accounts = AccountManager.get(this).getAccounts();

        for (Account account : accounts) {
           if (emailIsOk(account.name)) {
                ((EditText)
findViewById(R.id.email_input)).setText(account.name);
                break;
            }
        }
    }

I've tried
if (Build.VERSION.SDK_INT > 4)

But It still crashes.

I want to support  android 1,6 and at the same time autocomplite e-
mail in other vesrions of SDK

This is my problem
Thant you

--
Kirill

-- 



Re: Suppoting android 1.6. VerifyError.

by Kostya Vasilyev » Fri, 18 Mar 2011 23:45:50 GMT


 You can use a version-dependent factory method, something along these lines:

interface IBlah { /* some methods here */ };

class BlahForAndroid_1_x implements IBlah { /* 1.x dependent code here */ };

class BlahForAndroid_2_x implements IBlah { /* 2.x dependent code here */ };

And finally:

IBlah obj;
if (Build.VERSION.SDK_INT > 4)
obj = new BlahForAndroid_2_x();
else
obj = new BlahForAndroid_1_x();

-- Kostya

18.03.2011 15:30, Kirill :
I've got a method like this one. I want to autocomplite e-mail in EditText. But application crashes private void setAccount() { Account[] accounts = AccountManager.get(this).getAccounts(); for (Account account : accounts) { if (emailIsOk(account.name)) { ((EditText) findViewById(R.id.email_input)).setText(account.name); break; } } } I've tried if (Build.VERSION.SDK_INT> 4) But It still crashes. I want to support android 1,6 and at the same time autocomplite e- mail in other vesrions of SDK This is my problem Thant you -- Kirill
-- Kostya Vasilyev -- http://kmansoft.wordpress.com --


Sponsored Links


Re: Suppoting android 1.6. VerifyError.

by Doug » Sat, 19 Mar 2011 01:49:32 GMT


 Basically, you want to prevent the VM from trying to load classes that 
contain references to classes and methods that don't exist in the target 
platform.  Wrapping the immediate code with a check for SDK_INT doesn't 
prevent the JVM class loader from trying to make sense of the symbols in a 
class at run time.

Doug




-- 



Re: Suppoting android 1.6. VerifyError.

by fadden » Sat, 19 Mar 2011 08:04:44 GMT


Other Threads

1. getApplicationContext() & AlertDialog.Builder

Shoot... I was kinda hoping they were in different parts of your code.  I'm
going to have to punt this one off to someone else...

Anyone?

----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------









> > > 

2. disable SMS threading in Android 2.0

How can I disable threading of SMS. I get many messages, from one
source but on different topics so they are not a thread. A plain list
of SMS messages would be a lot easier to read. So how can the thread
view be turned off?

-- 

3. Can I use an old Android phone for development purposes?

4. Best and fastest way to load data?

5. raw mic data range

6. Not able to get Street Intersection addresses

7. Can key presses be intercepted when the device is sleeping?