How do I get data within an Android Service that was passed from an invoking Activity?
How do I get data within an Android Service that was passed from an
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First Context (can be Activity/Service etc)
For Service, you need to override onStartCommand there you have direct access to
intent:You have a few options:
1) Use the Bundle from the Intent:
2) Create a new Bundle
3) Use the putExtra() shortcut method of the Intent
New Context (can be Activity/Service etc)
NOTE: Bundles have “get” and “put” methods for all the primitive types, Parcelables, and Serializables. I just used Strings for demonstrational purposes.