I have an activity class that has started a service (within same
application). How do I extract the values set in the service class?
Here is the code snippet:
class MyActivity extends Activity {
private Intent svcIntent;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
svcIntent = new Intent(this, MyService.class);
startService(svcIntent);
setContentView(R.layout.main);
//---Button view---
Button btnOpen = (Button) findViewById(R.id.btnGetSvcData);
btnOpen.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Parcelable loc = svcIntent.getParcelableExtra
("CURR_VALUE");
...
}
}
public class MyService extends Service {
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
....
intent.putExtra("CURR_VALUE", loc); // loc is
Parcelable here
}
When stepping through the debugger, the intent object in
MyService.onStart seems to be different from the intent object passed
in startService in MyActivity -- I thought they should be the same
(intent id is different). As a result, getParcelableExtra is always
null in MyActivity; although it is set in MyService.
How can MyActivity get the values set at runtime in MyService (I don't
want to persist the values in db/file).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---