How to pass a variable to a new activity via intent ?

by Emre A. Yavuz » Thu, 17 Sep 2009 06:43:54 GMT

Sponsored Links


I'd like to pass a variable to a new activity which I start using an Intent. I 
know that I need to use the putExtra() method on the intent which I create in 
the old Activity. I also know that I need to use the getIntExtra() method 
(assuming that the variable I am trying to pass is an Integer) to grab it in 
the new Activity.


Here comes the problem;


I have to call the method getIntExtra() on an Intent in the new Activity, yet I 
am not sure what that Intent would be. How can I get a hold of the Intent which 
I created in the old Activity ? Any suggestions ?


Thanks in advance,


With regards,



New! Faster Messenger access on the new MSN homepage 

Other Threads

1. Receive large sms

Hi all,
I'm working with a module that receive sms and have a problem with
large sms(more than 160 chars).
The sms messages are received by a class extends
BroadcastReceiver.Below is the "onReceive" function
public void onReceive(Context context, Intent intent) {

            SmsMessage[] messages = getMessagesFromIntent(intent);
            if(null == messages)

            try {
                     for (int i = 0; i < messages.length; i++) {
                        SmsCallback callback = new
                        if(callback != null) {
                                callback.number =
                                callback.body = 
                                callback.timestamp = 
                        catch(Exception e) {
//dispatcher is declare in "": Executor dispatcher =

with the normal sms, everything is ok. But with the large sms(ie: sms
is divided into 2 parts). the "callback" of this sms is not called
with part#1(messages[0]).But It's called with part#2(message[1]).  So
the body message is not match.
Please help me, thanks.


2. Interconnecting emulators by network

Hello Dries,

I'm currently working on this emulator interconnection and emulator
multicast support
and I've downloaded your patches and compiled them.

Before I try them, I would like to know if you use any special command
line arguments to start the emulator,
or instead, if this network support is already built in in your

Please note that I haven't read your code yet, as I've stumble on this
thread some minutes ago.

It would be great if you could help me on this.



3. problem building android image for gumstix overo

4. Newbie Samsung Galaxy Spica

5. Problem with self-compiled kernels

6. Apk blapk market

7. strange exception when calling getBlob