7 messages in com.googlegroups.android-developers[android-developers] bindService() do...
FromSent OnAttachments
Ahmy21 May 2008 11:00 
Megha Joshi22 May 2008 13:53 
Mark Murphy22 May 2008 14:11 
Megha Joshi22 May 2008 14:38 
Mark Murphy22 May 2008 14:54 
Megha Joshi22 May 2008 15:48 
Ahmy24 May 2008 17:39 
Subject:[android-developers] bindService() does not start the service
From:Ahmy (ahmy@gmail.com)
Date:05/21/2008 11:00:05 AM
List:com.googlegroups.android-developers

a have a activity called ClientAYmsg.java , a Serivice name AYmsgService.java, an AIDL called IAYmsgService.aidl (which automatically create IAYmsgService.java) and a java class Called AYmsg.java

the ClientAYmsg.java only filled with onCreate like this : public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); AYmsg aymsg = new AYmsg(this); }

the constructor in AYmsg only called bind Service :

private ServiceConnection mConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { Log.d(TAG, "Connected"); mService = IAYmsgService.Stub.asInterface(service); }

public void onServiceDisconnected(ComponentName className) { mService = null;

} };

public AYmsg(Activity activity) {

activity.bindService(new Intent(IAYmsgService.class.getName()), mConnection, Context.BIND_AUTO_CREATE); Log.d(TAG, "Starting the service"); };

I already impelent the onBind(Intent intent) on the AYmsgService.java like this: @Override public IBinder onBind(Intent intent) { Log.i(TAG,"AYmsgService: onBind"); if (IAYmsgService.class.getName().equals(intent.getAction())) return mBinder; return null; }

but the bindService doesnt start the service.

but if i called it direcly with :

Intent i = new Intent(activity, AYmsgService.class); activity.startService(i,null);

the service works fine.

any body know what's seems to be the problem ?

thanx b4.