android - Check if Activity is Started with an Intent and If String Extra is passed in -
i want activity started activity, trying check if activity started activity. if not want disable fields , pop alert. no matter how try check this, nullpointerexception
here attempt.
intent intent = this.getintent(); if (intent != null && intent.getstringextra("uid").equals(null)) { showalert(); disablefields(); } else { muid = getintent().getstringextra("uid"); } how can refactor pass?
here npe 
intent.getstringextra("uid").equals(null) won't save nullpointerexception, since you'll calling method on null reference if there's not key "uid". can use hasextra() method check whether passed intent.
Comments
Post a Comment