7 messages in com.googlegroups.android-developers[android-developers] bindService() do...| From | Sent On | Attachments |
|---|---|---|
| Ahmy | 21 May 2008 11:00 | |
| Megha Joshi | 22 May 2008 13:53 | |
| Mark Murphy | 22 May 2008 14:11 | |
| Megha Joshi | 22 May 2008 14:38 | |
| Mark Murphy | 22 May 2008 14:54 | |
| Megha Joshi | 22 May 2008 15:48 | |
| Ahmy | 24 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.
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to andr...@googlegroups.com To unsubscribe from this group, send email to andr...@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---




