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. Video playlist and javax.microedition

Anyone knows if Android 1.5 support video playlist format such SMIL? Also 
Android SDK doesn't include all the classes in J2ME such as: 
javax.microedition.media.protocol.DataSource
Thanks
Alan

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

2. i have problem with gps .

can i emulate app with gps on emulator? and any sample code for gps

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

3. Replacement for 'Recent Tasks' App (longpress home key)

4. sdcard mounted but not detected by android system.

5. How to install apk files in androd 1.5 using Eclipse IDE and what are the .apk files that should be installed???

6. Eclipse : Unknown error: SDK is not loaded yet. * upgrade failed *

7. Want to earn online $400 to $500 per month !!!!