tags:

views:

88

answers:

1

Yes, I know. It sounds weird, but I can't think of any other way to explain it.

I start Activity MainActivity. It calls startActivity(B). B calls startActivity(C). In C, I have a button with an onClickListener that looks like this:

startActivity(new Intent(getApplicationContext(), MainActivity.class));

When I hit the button, I get to activity B, not Main!

LogCat shows this:
Activitymanager Starting activity: ... MainActivity
ActivityManager Starting activity: ... B

So, it looks like my MainActivity (A) gets started and then something-or-someone-mysterious starts activity B immediately.

Ideas? I'm at a loss...

Thanks!
Llappall

EDIT: A couple of notes to clarify:
1) I'm not overriding any lifecycle methods in MainActivity. I just have onCreate.
2) MainActivity's layout shows an image that covers the whole screen. I capture where the user touches in the image's OnTouchListener and, depending on that, I call different intents. The code looks like this:

if (touchX > 0 && touchX < 0.5 && touchY > 0.25
    && touchY < 0.46) {
    Intent i = new Intent(context, ShowListsActivity.class);
    i.putExtra("option", 0);
    startActivity(i);
} else if // if the location of the click is different I call another .class
+1  A: 
Christopher
Christopher, thanks for the explanation. As you can see in my edit of the question, my activity B _should_ start only when the user touches the screen. That is what's so perplexing about this: it is like the image's onTouchListener is being raised without the user's input.
llappall
Another question, if I may abuse of your help: you say I should use "this" instead of "getApplicationContext()". I've seen examples of both, but don't really understand what is the difference. What is that parameter used for? I understand one is the App context, the other is the current activity. What I don't get is why does that mater?
llappall