• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Dov Ezra
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 228
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Dov Ezra
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you call the Service's methods without binding to it?

 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!