我在应用程序中使用了android-parse服务器。下面是解析email列的db屏幕截图。电子邮件列在数据库中隐藏密码列之后。
我的问题是
当我将电子邮件ID检索到电子邮件客户端时,即使电子邮件列中包含电子邮件,电子邮件也为null 。
注意:在另一个地方(另一个表)的应用程序中,我以相同的方式将电子邮件ID拉到电子邮件客户端,但是邮件显示得很好..仅在这里出现问题。
如果有人知道请帮忙吗?
这是解析数据库中的电子邮件列
try{ JSONObject jsonObject = parseObjectToJson(object); Log.d("Object", jsonObject.toString()); Log.d("Email", "+" + object.get("email")); personNumber = jsonObject.getString("telephone"); personEmail = jsonObject.getString("email"); }catch (JSONException je){ }catch (ParseException pe){ }
this is email button
emailPerson = (Button)findViewById(R.id.individualEmail); emailPerson.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Intent.ACTION_SEND); i.setData(Uri.parse("mailto:")); i.setType("plain/text"); i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {personEmail}); startActivity(i); } }); if(personEmail==null || personEmail.equals("") || personEmail.equals(" ")){ emailPerson.setClickable(false); emailPerson.setEnabled(false); emailPerson.setVisibility(View.GONE); } else{ emailPerson.setEnabled(true); emailPerson.setClickable(true); emailPerson.setVisibility(View.VISIBLE); }
here it is working fine but this is a different table in same database . >in this table there is no hidden password field
try{ corporateEmail = jsonObject.getString("email"); if(corporateEmail == null || corporateEmail.equals("")){ emailCorporate.setVisibility(View.GONE); emailCorporate.setEnabled(false); emailCorporate.setClickable(false); }
emailCorporate = (Button) findViewById(R.id.corporateEmail); emailCorporate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Intent.ACTION_SEND); i.setData(Uri.parse("mailto:")); i.setType("plain/text"); i.putExtra(Intent.EXTRA_EMAIL, new String[] {corporateEmail}); startActivity(i); } });
private JSONObject parseObjectToJson(ParseObject parseObject) throws ParseException, JSONException, com.parse.ParseException { JSONObject jsonObject = new JSONObject(); parseObject.fetchIfNeeded(); Set<String> keys = parseObject.keySet(); for (String key : keys) { Object objectValue = parseObject.get(key); if (objectValue instanceof ParseObject) { jsonObject.put(key, parseObjectToJson(parseObject.getParseObject(key))); } else if (objectValue instanceof ParseRelation) { } else { jsonObject.put(key, objectValue.toString()); } } return jsonObject; }
如果jsonObject不为null,请检查您从中提取数据的解析数据库是否具有“ email”标
jsonObject