*
public* *class* SmsReceiver *extends* BroadcastReceiver
{
//..........................
@Override
*public* *void* onReceive(//...................,...........)
{
//................................
Intent i = *new* Intent(contx, NoteEdit.*class*);
i.putExtra(NotesDbAdapter.*KEY_ROWID*, id);
i.putExtra(NotesDbAdapter.*KEY_TITLE*, c.getString(
c.getColumnIndexOrThrow(NotesDbAdapter.*KEY_TITLE*)));
i.putExtra(NotesDbAdapter.*KEY_BODY*, c.getString(
c.*getColumnIndexOrThrow*(NotesDbAdapter.*KEY_BODY*)));
startActivity(i);
}
//....................................
}
*
public* *class* NoteEdit *extends* Activity
{
Bundle extras = getIntent().getExtras();
*if* (extras != *null*) {
String title = extras.getString(NotesDbAdapter.*KEY_TITLE*);
String body = extras.getString(NotesDbAdapter.*KEY_BODY*);
mRowId = extras.getLong(NotesDbAdapter.*KEY_ROWID*);
}
is this ok with you?
On Thu, Oct 8, 2009 at 1:01 AM, Sparky <[email protected]> wrote:
>
> Thanks Justin!
>
> I have spent like an hour looking for this simple but trivial
> information. Every source is talking about how to invoke intents and
> put extra info in it, but no one says how to actually use it in the
> invoked application. :-/
>
> On Oct 6, 8:31 am, Justin Anderson <[email protected]> wrote:
> > Turns out I just barely had to do something similar...
> >
> > In order to get the data from the intent you created, you need to do the
> > following in the activity that is started:
> >
> > Bundle extras = getIntent().getExtras();
> > if (extras != null)
> > {
> > ...do stuff...
> > String value = extra.getString("myKey");
> >
> > }
> >
> > Thanks,
> > Justin
> >
> > ----------------------------------------------------------------------
> > There are only 10 types of people in the world...
> > Those who know binary and those who don't.
> > ----------------------------------------------------------------------
> >
> > On Mon, Oct 5, 2009 at 10:46 PM, <[email protected]> wrote:
> > > if you do simply as you written & if what ever clear from your post to
> me
> > > here the activity will start every time you receive the message?is it
> ok
> > > with you?but if you want to start some activity from user will will
> acess
> > > the receivid data then just save that data some where n the acess it
> from
> > > user activity.
> >
> > > On Mon, Oct 5, 2009 at 10:28 PM, Anders Feder <
> [email protected]>wrote:
> >
> > >> Aha. So I will do something like this in the BroadcastReceiver:
> >
> > >> myIntent.putExtra("x","y");
> > >> myActivity.startActivity(myIntent);
> >
> > >> And then in myActivity.onCreate() do something like:
> >
> > >> DoSomething(myBundle.getBundleExtra("x"));
> >
> > >> Does that look about right?
> >
> > >> If so, how do I tell, in onCreate(), whether the Activity was started
> by
> > >> the user or by my BroadcastReceiver?
> >
> > >> Thanks a lot,
> >
> > >> Anders Feder
> >
> > >> 2009/10/5 Justin Anderson <[email protected]>
> >
> > >> Use Intent.putExtra() to add the data you want to pass to the activity
> you
> > >>> are starting. There are several different versions of putExtra
> depending on
> > >>> the data you want to pass.
> >
> > >>> Then the activity you are starting can get that information from the
> > >>> bundle that is passed in via onCreate().
> >
> > >>> I have never actually done this, but I believe that is how it
> happens...
> > >>> If I am wrong, could somebody please correct me?
> >
> > >>> Thanks,
> > >>> Justin
> >
> > >>>
> ----------------------------------------------------------------------
> > >>> There are only 10 types of people in the world...
> > >>> Those who know binary and those who don't.
> > >>>
> ----------------------------------------------------------------------
> >
> > >>> On Mon, Oct 5, 2009 at 9:16 AM, Anders Feder <
> [email protected]>wrote:
> >
> > >>>> Thanks for your response, but could you please elaborate a bit? I
> don't
> > >>>> have the lingo that straight yet. What exactly should I do? Should I
> add
> > >>>> something in the AndroidManifest file? If so what, and where? Thanks
> again.
> >
> > >>>> Anders Feder
> >
> > >>>> 2009/10/5 <[email protected]>
> >
> > >>>> just add that extra bundle to intent & start new activity with this
> > >>>>> extra.in the activity just retrive the bundle you added to it.
> >
> > >>>>> On Mon, Oct 5, 2009 at 5:12 AM, Anders Feder <
> > >>>>> [email protected]> wrote:
> >
> > >>>>>> Hi,
> >
> > >>>>>> I'm developing an application with android.telephony.gsm that is
> > >>>>>> supposed to process incoming SMS messages.
> >
> > >>>>>> I've figured out that I need to have a BroadcastReceiver for
> receiving
> > >>>>>> the incoming messages. But how am I supposed to pass the received
> > >>>>>> messages from the BroadcastReceiver and on to my Activity?
> >
> > >>>>>> Thanks in advance,
> >
> > >>>>>> Anders Feder
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---