File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Android and the fly likes how to start a service from activity and how to call the service methods? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "how to start a service from activity and how to call the service methods?" Watch "how to start a service from activity and how to call the service methods?" New topic
Author

how to start a service from activity and how to call the service methods?

Dov Ezra
Greenhorn

Joined: Nov 23, 2010
Posts: 21
Hello,

I'm trying to fallow this tutorial for building a media player for android.

The tutorial talks about a service class
The code for binding service from the tutorial dose not compile in my system.
.

but this one dose:


(maybe the tutorial use earlier api version then mine? I'm using Android 2.2, API Level 8. )

anyway, my code compile and the call to bindService return true, but still my service object is null.
also the object m_connection whitch is a ServiceConnection stays null after bindService().
m_connection is defined at the begiining of the activity class, along with all data members:


of caurse m_IAudioPlayer is null too. if i tray to call any of the service mmethod
via m_IAudioPlayer.method() I get the null pointer exception.
what am I doing wrong with binding the service? or init or communicate with it?

why do I need this aidl interface actually? I saw code examples that starts a service without
using this interface?







James Elsey
Ranch Hand

Joined: Dec 21, 2007
Posts: 228

Don't think I've ever had to explicitly bind a service..

I normally just create a service, then call startService()

Don't have any access to my droid code here, but will check later tonight


Kind Regards, James. OCPJP 1.6 || My SCJP / OCJCP Study Notes
Interested in : SCJP, Google App Engine, Stripes, Android;|| My Bite-Size SCJP Study Blog
Dov Ezra
Greenhorn

Joined: Nov 23, 2010
Posts: 21
Can you call the Service's methods without binding to it?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to start a service from activity and how to call the service methods?
 
Similar Threads
how call default Telephone App, or Skype App in Android and automatically initial a call
Android Accelerometer Sensor
AppWidget problem
Beginning Android, activity / service question
How to make your application to run as the Phone Boots up?