0

Title self explanatory, how can I do that?

I've tried classic intent method but the getIntent() part doesn't work inside my activity extends IntentService..

m4tt
  • 825
  • 1
  • 11
  • 28

1 Answers1

1

You don't need to call getIntent() from the IntentService.

You get the intent as a parameter when your IntentService starts running (with onHandleIntent()). You can then read the extras normally with getStringExtra(). Check the code below:

@Override
    protected void onHandleIntent(Intent intent) {
    String username = intent.getStringExtra("key_1");
    String password = intent.getStringExtra("key_2");
    // Code here ...
}

Check this link for more: Using putExtra to pass values to intent service

Community
  • 1
  • 1
Evin1_
  • 12,292
  • 9
  • 45
  • 47
  • The problem is, my variable's intent is called iii and the onHandle is (Intent intent) cause is an intent to deal with notification, indeed using `String from = iii.getStringExtra("notesArrayy");` inside the onHandle doesn't resolve iii, so how am I suppose to move? thanks – m4tt Jan 24 '16 at 15:04
  • 1
    Calling intent.getStringExtra() inside your onHandleIntent would reference to your original iii Intent. Java is just renaming your Intent, but the reference is the same. Check http://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value for more. – Evin1_ Jan 24 '16 at 15:50