Michelle
Michelle

Reputation: 2900

Intent being sent multiple times

I'm calling startActivityForResult() once on a menu item click, but the intent is being fired three times: my LogCat is showing "Starting: Intent" three lines in a row (and then "Displayed package name" three lines in a row, etc). The app runs seemingly normally - the activity opens, runs, and exits fine, but everything in my log is tripled. The problems start when I get back to onActivityResult() and every line is being executed three times. Is there any reason for an intent to be fired multiple times like that, and any way to fix it?

Here's the code calling startActivityForResult():

public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
  case R.id.messageconfig:
    Intent mIntent = new Intent(this, MessageConfig.class);
    mIntent.putStringArrayListExtra(KEY_MESSAGES, data.getMessages());
    startActivityForResult(mIntent, MESSAGE_CONFIG_CODE);
    return true;

Let me know if you need any more info, and thanks in advance.

Upvotes: 0

Views: 659

Answers (1)

Ovidiu Latcu
Ovidiu Latcu

Reputation: 72311

That is a bug in the Emulator. It happens to me daily... yet another Android issue... This will never happen on a real device. I think the bug is just in the Logging process... because the code is executed just once but logged 3 or several times.

Upvotes: 1

Related Questions