我的代码很简单,我需要通过邮件发送从openweathermap下载的数据。
Barometr.java:
public void getPressure(JSONObjesc jObject){
try{
JSONObject cis = jObject.getJSONObject("main");
pressure = cis.getInt("pressure");
}catch(Exception e){
Log.e("Barometr", "Error");
}
}
BarometrActivity(主要类):
private void showMailDialog(){
AlertDialog.Builder sendmail = new AlertDialog.Builder(this);
sendmail.setTitle("Send mail to:");
final EditText adress = new EditText(this);
adress.setInputType(InputType.TYPE_CLASS_TEXT);
sendmail.setView(adress);
sendmail.setPositiveButton("Send", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent mail = new Intent(Intent.ACTION_SEND);
mail.setType("text/plain");
mail.putExtra(Intent.EXTRA_EMAIL, new String[] {adress.getText().toString()});
mail.putExtra(Intent.EXTRA_SUBJECT, "Pressure");
mail.putExtra(Intent.EXTRA_TEXT, "sample");
try {
startActivity(Intent.createChooser(mail, "Send mail"));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(BarometrActivity.this, "Missing app.", Toast.LENGTH_SHORT).show();
}
}
});
sendmail.show();
}
我想在电子邮件中提供带有样本描述的压力信息。
你能告诉我怎么办?