Wednesday, 15 February 2012

How to find where android service is created from? -


I'm thinking how an Android service is created from? For example, I have two different activities and some buttons. When a user clicks on a button, he will start the service, but how can I verify that the service was created with the activity that I expected?

Service class:

  Expands public class Bluetooth service service {...}  

Activity class:

  public class settings enhances activity activity {@Override Creates Secure Zero (Bundle Saved InstantState) {super.onCreate (savedInstanceState); } / ** This is a button * / Public vs createBluetoothService (see view) {intent = new intent (this, BluetoothService.class); (In) startService; }}  

Thanks for any help.

Please tell me that the question is not clear.

@conradrokiyak with suggestions, I am just writing the answer to my question

  Public category settings expands activity activity {@ Override Creature (bundled saved instenstate) on protected void {super.onCreate (SavedInstanceState); } / ** This is a button * / Public vs createBluetoothService (see view) {intent = new intent (this, BluetoothService.class); In.putExtra ("class", "setting power"); (In) startService; }}  

Service class:

  Expands public class Bluetooth service service {... @ Override Public Intent Start Commands (Intent Intent, Int.) Flag, int start etc.) {bundle bundle = intent. String check = bundle .get string ("square"); If (check.equals ("SettingsActivity")) {// do something} return START_STICKY; }}  

Thanks for the tips it is working great for me.


No comments:

Post a Comment