Android在Android中检查null或空字符串
在尝试中,AsyncTask我从服务器获取电子邮件地址。在onPostExecute()我必须检查的是电子邮件地址empty或null。我使用以下代码进行检查: if (userEmail != null && !userEmail.isEmpty()) { Toast.makeText(getActivity(), userEmail, Toast.LENGTH_LONG).show(); UserEmailLabel.setText(userEmail); } 但在我Toast看来null是印刷的。我的完整代码: private class LoadPersonalData extends AsyncTask<String, Void, Void> { @Override protected void onPreExecute() { super.onPreExecute(); } protected Void doInBackground(String... res) { List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("user_id", PrefUserName)); params.add(new BasicNameValuePair("type", type_data)); JSONObject json = jsonParser.makeHttpRequest(Url, "POST", …