views:

536

answers:

2

Hi all,

Have a question about sending data between classes and activities.

I currently have a class that monitors outgoing class and gets the number of an outgoing call.

I instantiate this class in my main Activity and run its method that retrieves the number.

However I now have another Activity that I want to pass the number to.

I start this Activity through an Intent from the class that gets the number.

So it works like this:

MainActiviy Starts > Starts Object that listens for outgoing call > outgoing call detected > Object gets outgoing number > object fires Intent to create new Activity after outgoing call logged and number retrieved > new Activity displays

I hope that is a bit clearer?

So I want to send the number from the class (object) to the new Activity that it has started.

So what is the simplest way to do this?

Thanks in advance

+3  A: 

Call putExtra() on the Intent you are using with startService(). Use putExtra() to store the phone number in the Intent. Use getExtra() in the service being started to retrieve the phone number.

CommonsWare
Thanks, I actually have it done, typically enough I was loking up the wrong ideas and eventually stumbled across it, thanks again
Donal Rafferty
+1  A: 

Pass the number as an extra: http://developer.android.com/intl/fr/reference/android/content/Intent.html#putExtra(java.lang.String, android.os.Parcelable[])

mbaird
Thanks :) actually came across it myself after looking up the wrong things!
Donal Rafferty