开发者

Android bindService / remote services - any basic examples?

开发者 https://www.devze.com 2022-12-13 06:15 出处:网络
As a newbie to Android development, I\'m trying to do the basics and build a media player. It works fine in one activity, but I\'m now moving the MediaPlayer stuff to a remote service so it can carry

As a newbie to Android development, I'm trying to do the basics and build a media player. It works fine in one activity, but I'm now moving the MediaPlayer stuff to a remote service so it can carry on after the activity is destroy. I've moved the necessary code to the service, left comments in the activity where I'll need to call service methods, implemented my AIDL and it all builds with no errors (Eclipse).

However, I'm totally stumped as to how to call IPC methods. Are there any simple and minimal examples with no fat - just the bare essentials?

As I'm using IPC methods, I don't need to use onStart() at all - right? (I intend to use LoadFile(File path), and then have public void considerDeath() { if (!isPlaying()) { MyService.stopSelf(); } } method called from activity.onDestroy )

/guide/developing/tools/aidl.html has mu开发者_开发技巧ltiple binders, but when I use the mSecondaryConnection portion, I get "MyService.Stub cannot be resolved"

I've tried http://www.anddev.org/remote_service_tutorial-t8127.html which seems to confuse things by overloading methods.

I can't find anything by Mark Murphy either on the subject :(


minicompact.com/mobiletalk/?p=18 is also just what I was looking for! (Incidently, I did use AIDL for a local service; it works!)

0

精彩评论

暂无评论...
验证码 换一张
取 消