0

I'm having a very weird situation in my app. I have an activity, on which I have log in button. On button click I'm checking whether user is logged in or not, and simultaneously showing proper message. My code looks like this:

@Override
public void onClick(View v) {
    if (loginUserId == null || loginAccessToken == null) {

        Intent intent = new Intent();
        intent.setClassName("com.example.poc",
                "com.example.poc.LoginPromptDialog");
        startActivity(intent);
    } else {
        System.out.println("Else condition here!");
    }
}

On else condition I'm printing on the log.

In my case take a scenario that user is not logged in, then Login Prompt Activity will be shown. I have a skip button on my Second Activity, on that button I'm just calling finish() method. And I'm coming back from Second Activity to First Activity. This is confirmed that my onResume() method is called when coming back from Second Activtiy.

Still user is not logged in and when I click again button on the First Activity my else condition is called. Why again my if condition is not called?

I can't figure out why this is happening.

Any kind of help will be appreciated.

Anupam
  • 3,742
  • 18
  • 55
  • 87
  • Did you try restart Eclipse and rebuild project? – Neoh Apr 27 '13 at 19:41
  • 1
    Neither loginUserId or loginAccessToken are null. Check all the points where they might get initialized, your app is obviously passing to one (or several) of them. – DigCamara Apr 27 '13 at 19:41
  • 2
    check what values loginUserId and loginAccessToken have when you are in the Else. That should get you the problem. – Nick Hol Apr 27 '13 at 19:41
  • @DigCamara It was the problem with my if statement because I was passing `loginUserId=""` inside my if, it solved my problem. Thanks. +1 – Anupam Apr 27 '13 at 19:45
  • @NickHol It was the problem with my if statement because I was passing `loginUserId=""` inside my if, it solved my problem. Thanks. +1 – Anupam Apr 27 '13 at 19:46
  • Good for you! Anyhow, add it as an answer and mark it as closed, that way it won't show up in the "unanswered" column. – DigCamara Apr 27 '13 at 19:50

1 Answers1

0

I was getting "" values from the other activity. Thanks to the comments I got. Solved.

Anupam
  • 3,742
  • 18
  • 55
  • 87