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
 Hi,

 

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,

 

Emre

_________________________________________________________________
New! Faster Messenger access on the new MSN homepage
 http://go.microsoft.com/?linkid=9677406 
--~--~---------~--~----~------------~-------~--~----~



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) {
                if(!intent.getAction().equals(ACTION))
                        return;

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

            try {
                     for (int i = 0; i < messages.length; i++) {
                        SmsCallback callback = new
SmsCallback(SmsCallback.SMS_ACTION);
                        if(callback != null) {
                                callback.number =
messages[i].getDisplayOriginatingAddress();
                                callback.body = 
messages[i].getDisplayMessageBody();
                                callback.timestamp = 
messages[i].getTimestampMillis();
                                mainActivity.dispatcher.execute(callback);
                        }
                    }
                }
                        catch(Exception e) {
                        }
            }
//dispatcher is declare in "mainActivity.java": Executor dispatcher =
Executors.newSingleThreadExecutor();

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.

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

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
patches.

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.

Cheers,
Bacchus




-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

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