putExtra

by Kevin J. Brooks » Sun, 10 May 2009 11:05:06 GMT


Sponsored Links
 I am trying to pass a simple string in to a new activity.  I feel a
little dense.  I have looked at the samples, and I just can't seem to
get it through my thick head.  What do I need in the first parameter.

        public static final String DRINK_TYPE = "type";
.
.
.
        Intent i = new Intent(this, BeerScreen.class);
        i.putExtra(DRINK_TYPE, "beer");


Then in BeerScreen.java

        String sType = extras.getString("type");
        if(sType == "beer"){

The code inside the if is not executed.  <sigh>

Kevin




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



putExtra

by Tejas » Sun, 10 May 2009 12:34:10 GMT


 Dude,
Use Java functions equals or compareTo, "==" operator won't work

Cheers,
Tej

On May 9, 11:04pm, "Kevin J. Brooks" <bear123434...@comcast.net>


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


Sponsored Links


putExtra

by Robert Slama » Sun, 10 May 2009 13:12:47 GMT


 Hi,

if you have static final String DRINK_TYPE you can use follow construct

if(className.DRINK_TYPE.equals("beer")){
}

or make new class just with constats
class IConstants
...
public static final String DRINK_TYPE = "type";
public static final String  BEER = "beer";
public static final String LAGER = "lager";
...


and next
if(IConstants.DRINK_TYPE.equals(IConstants.BEER)){
...
}



2009/5/10 Kevin J. Brooks <bear123434...@comcast.net>:

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



Other Threads

1. lucene api

hi i am new to android .
i have developed a application
in that application i want a feature of global search in xml file
now  i want to use Lucene api for global search
can i use in android?

if yes than plz tell me how can i implements that in my android code

thanx
jaimin.

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

2. Development on the MyTouch 3G

I just ordered a myTouch 3G from T-Mobile (it will come locked). My
main motivation is to do Android Development on this phone. I just
read on the Android Development Site 
http://developer.android.com/guide/developing/device.html
that one can develop Android apps on the "Developer Phone" or the
Classic "G1".

Can I develop apps using my myTouch 3G? I guess it boils down to 2
things:

- Can I use the myTouch 3G to test apps that I develop using Eclipse?

- Can I use the myTouch 3G device itself as an app development
platform?

Thanks,


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

3. installation woes...

4. clear activity stack and replace with a new activity

5. Routing audio to within the call

6. Issue (bug) reports because of custom ROMS, varying configurations, etc.

7. Inspecting the contents of an Intent