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 null pointer exception

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

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -