onCreate for a service does not take any parameters, when i put it
there (or anywhere in GetContacts.java i get syntax error  "the method
getIntent() is undefined for the type GetContacts"  ???

On Apr 16, 1:32 pm, "Michael Novak" <[EMAIL PROTECTED]> wrote:
> it goes before you call the extras first.... i would say onCreate.
>
> On Wed, Apr 16, 2008 at 1:23 PM, franw <[EMAIL PROTECTED]> wrote:
>
> > where does this go?
> > in onStart, in run ?? onCreate of the service?
>
> > On Apr 16, 12:56 pm, "Michael Novak" <[EMAIL PROTECTED]>
> > wrote:
> > > you should call...... for example
>
> > > Bundle extras = getIntent().getExtras();
>
> > > then
>
> > > extras.getString(KEY, VALUE);
>
> > > -mike
>
> > > On Wed, Apr 16, 2008 at 12:51 PM, franw <[EMAIL PROTECTED]> wrote:
>
> > > > hi, can anybody help - ive got an intent receiver that starts a
> > > > service, and i want to send data via the intent for the service OR  a
> > > > bundle - neither seem to work.  my data is always empty strings, as
> > > > initialized in the service .
> > > >  i thought onStart of the service was the place to pick up the data -
> > > > even when i hard code my userid, password, and email in the onStart of
> > > > my service, i still get empty strings.?????  arggh!
>
> > > > intent receiver and service follow.
> > > > tyia,
> > > > fran w
>
> > > > import org.apache.android.mailContactsOften.GetContacts;
> > > > import android.app.Service;
> > > > import android.database.Cursor;
> > > > import android.os.Binder;
> > > > import android.os.IBinder;
> > > > import android.os.Parcel;
> > > > import android.content.Intent;
> > > > import android.os.Bundle;
>
> > > > public class GetContacts extends Service
> > > > {
> > > >        String pList = "";
> > > >        String st = "";
> > > >    String userid = "";
> > > >    String password="";
> > > >    String email="";
>
> > > >        public void onStart(Intent in, Bundle b)
> > > >        {
> > > >        //userid = b.getString("userid");
> > > >                //password = b.getString("password");
> > > >                //email = b.getString("email");
>
> > > >                userid = in.getStringExtra("userid");
> > > >                password = in.getStringExtra("password");
> > > >                email = in.getStringExtra("email");
>
> > > >      //NOTE:  hard coding of userid, password and email here STILL
> > > > results
> > > >         //  empty strings being passed to run()
>
> > > >        }
>
> > > >       [EMAIL PROTECTED]
> > > >    protected void onCreate()
> > > >    {
> > > >        Thread thr = new Thread(null, mTask, "GetContacts");
> > > >        thr.start();
> > > >    }
>
> > > >    /**
> > > >     * The function that runs in our worker thread
> > > >     */
> > > >    Runnable mTask = new Runnable() {
> > > >        public void run()
> > > >        {
> > > >            // Normally we would do some work here...
> > > >                // get the contact string and call send to send the
> > info
> > > >                String body = getContactStr();
>
> > > >                // send the data
> > > >                SendContacts s = new SendContacts (body,userid,
> > password,
> > > >                                email);
>
> > > >            // Done with our work...  stop the service!
> > > >            GetContacts.this.stopSelf();
> > > >        }
> > > >    };
>
> > > > .... rest of service routines, etc.
> > > > here is the intent receiver
>
> > > > import android.content.Context;
> > > > import android.content.Intent;
> > > > import android.content.IntentReceiver;
> > > > import android.os.Bundle;
>
> > > > public class EmailContactsRepeat extends IntentReceiver
> > > > {
> > > >        String userid ;
> > > >        String password ;
> > > >        String email ;
> > > >       [EMAIL PROTECTED]
> > > >    public void onReceiveIntent(Context context, Intent intent)
> > > >    {
> > > >        //get bundle of extras (userid, passwork, email) from intent
> > > >                userid = intent.getStringExtra("userid");
> > > >                password = intent.getStringExtra("password");
> > > >                email = intent.getStringExtra("email");
> > > >        //context.startService(new Intent(context, GetContacts.class),
> > > >        //      null);
>
> > > >        Intent conintent = new Intent(context, GetContacts.class);
> > > >        //bundle  data for conintent
>
> > > >        // bundle extras (data) with the intent.
> > > >        conintent.putExtra("userid", userid);
> > > >        conintent.putExtra("password", password);
> > > >        conintent.putExtra("email", email);
>
> > > >                Bundle b= new Bundle();
> > > >                b.putString("userid", userid);
> > > >                b.putString("password", password);
> > > >                b.putString("email", email);
>
> > > >        context.startService(conintent,b);
>
> > > >    }
> > > > }- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to