I am making an Android app that captures a user's e-mail through the displayEmailCaptureFragment() method. If I already captured the user's e-mail, I do not want to prompt the user to enter their e-mail again.
I declare the customerEmailAddress String right after my MainActivity but before the onCreate method:
public class MainActivity extends FragmentActivity implements View.OnClickListener, BillingProcessor.IBillingHandler,
EmailCapturedListener {
private MyPagerAdapter pageAdapter;
private Button mDownloadResumeButton;
private ImageButton mRightArrow, mLeftArrow;
private static final String EMAILKEY = "email_key";
public static final String EDITSKU = "professional_editing_service_1499";
public static final String EMAILSKU = "resume_template_pro_99";
private static final String RBPEMAIL = "rbproeditor@gmail.com";
private static final String RBPPASSWORD = "Redhawks123";
public String customerEmailAddress;
I then have an OnClick() method based on a user's response action within the app. Essentially, I am try to allow for a certain activity after the onClick if the user already entered their e-mail address. If they did not enter their e-mail address, then I prompt them to enter their e-mail and save it to shared preferences. I use a basic if - else statement, however I am still generating a null pointer exception even though I assign the customerEmailAddress string:
@Override
public void onClick(View v) {
int currentPosition = pager.getCurrentItem();
switch (v.getId()) {
case R.id.right_arrow:
pager.setCurrentItem(currentPosition + 1);
break;
case R.id.left_arrow:
pager.setCurrentItem(currentPosition - 1);
break;
case R.id.download_resume_button:
customerEmailAddress = mPrefs.getString(EMAILKEY, null);
if (customerEmailAddress.equals(null)){
displayEmailCaptureFragment();
}
else {
showPurchaseDialog();
}
break;
}
}
Any help is appreciated!