1

I have created Service which contains several notifications in the foreground to indicate its status (searching, lock, disabled... etc.). I would like a way to add a PendingIntent which points to the activity that called my service (there may be several activities that can call or bind to this service). Is there a way to relay the activity class where the StartService(Intent) was called, via the Intent.

My intention is to not hard code the activity class(es) into the service, but instead pull the .class from the intent, in the services onStartCommand(...).

CodyF
  • 4,977
  • 3
  • 26
  • 38
  • 2
    you can put a class in an intent's extras. – njzk2 Nov 06 '14 at 19:46
  • 1
    Why do you need to know which activity called the service? Perhaps you need to rethink your design? – Code-Apprentice Nov 06 '14 at 19:56
  • `setClass` will not do what you want, you'll need `putExtra` in the intent you use to call the service. – njzk2 Nov 06 '14 at 19:57
  • 1
    My goal was to make the foreground Notification navigate the user back to the starting activity when depressed. – CodyF Nov 06 '14 at 20:00
  • I see, I did not realize I could put a class into the extras. I didn't see a function with a Class input parameter; but I just saw that any Serializable can be used as an extra – CodyF Nov 06 '14 at 20:06

0 Answers0