great! i will try that -
am i getting my bundled extras correctly (via onBind)?


On Apr 14, 5:40 pm, "Megha Joshi" <[EMAIL PROTECTED]> wrote:
>  Hi,
>
>  This is because the startManagingCursor() method is not present in Service
> class, it can only be used for Activity.
>
>  You don't need this method in service, you can simply use the cursor, and
> be careful about closing it with cursor.close() when you are done.
>
>  Thanks,
>  Megha
>
>
>
> On Mon, Apr 14, 2008 at 1:49 PM, franw <[EMAIL PROTECTED]> wrote:
>
> > hi megha,
> > i made my program into a service - i have extras for my intent, so i
> > hope the ibind is the place to pick the extras up -
> > the only thing that is hanging now is that
>
> >                startManagingCursor(c);
>
> > is showing an error of "the method startManagingCursor(Cursor)  is
> > undefined for the type GetContacts"
>
> > here is GetContacts as a service
>
> > package org.apache.android.mailContactsOften;
>
> > import org.apache.android.mailContactsOften.GetContacts;
> > import android.app.Service;
> > import android.app.Activity;
> > import android.app.NotificationManager;
> > import android.database.Cursor;
> > import android.os.Binder;
> > import android.os.Bundle;
> > import android.os.IBinder;
> > import android.os.Parcel;
> > import android.content.ContentResolver;
> > import android.content.Intent;
>
> > public class GetContacts extends Service
> > {
> >        String pList = "";
> >        String st = "";
> >        String userid ;
> >        String password ;
> >        String email ;
> >        int rbutton ;
> >        String body;
>
> >   [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
> >                body = getContactStr();
>
> >                // send the data
> >                 SendContacts s = new SendContacts (body,userid, password,
> >                                email,rbutton);
>
> >             // Done with our work...  stop the service!
> >            GetContacts.this.stopSelf();
> >        }
> >    };
>
> >   [EMAIL PROTECTED]
> >    public IBinder onBind(Intent intent)
> >    {
> >                userid = intent.getStringExtra("userid");
> >                password = intent.getStringExtra("password");
> >                 email = intent.getStringExtra("email");
> >                int foo=0;
> >                 rbutton = intent.getIntExtra("rbutton", foo);
> >         body = intent.getStringExtra("body");
> >        return mBinder;
> >    }
>
> >    /**
> >     * This is the object that receives interactions from clients.
> > See RemoteService
> >     * for a more complete example.
> >     */
> >    private final IBinder mBinder = new Binder()
> >    {
> >       [EMAIL PROTECTED]
> >                protected boolean onTransact(int code, Parcel data, Parcel
> > reply,
> > int flags) {
> >            return super.onTransact(code, data, reply, flags);
> >        }
> >    };
>
> >    public String getContactStr()
> >    {
> >        pList = "";
> >         st = "";
>
> >        Cursor c = getContentResolver().query(
> >                android.provider.Contacts.Phones.CONTENT_URI,
> >                null, null, null,
> >                android.provider.Contacts.Phones.PERSON_ID+ " ASC");
>
> >                startManagingCursor(c);
>
> > .....rest of routine
> > }
>
> > here is the new receiver
>
> > package org.apache.android.mailContactsOften;
>
> > import android.content.Context;
> > import android.content.Intent;
> > import android.content.IntentReceiver;
>
> > public class EmailContactsRepeat extends IntentReceiver
> > {
> >   [EMAIL PROTECTED]
> >    public void onReceiveIntent(Context context, Intent intent)
> >    {
> >        //get bundle of extras (userid, passwork, email) from intent
> >                String userid = intent.getStringExtra("userid");
> >                String password = intent.getStringExtra("password");
> >                String email = intent.getStringExtra("email");
> >                int foo=0;
> >                int rbutton = intent.getIntExtra("rbutton", foo);
>
> >         String body = intent.getStringExtra("body");
>
> >        //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);
> >        conintent.putExtra("rbutton", rbutton);
> >                conintent.putExtra("body",body);
>
> >        context.startService(conintent,null);
>
> >    }
> > }- 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 android-developers@googlegroups.com
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