我在 html 文件和 java 代码中有一个用于通过电子邮件共享图像的按钮,现在我需要将 java 中按钮代码的“onclick”放到 html 的“onClick”中,以通过 phonegap 中的电子邮件实现“数据共享”。因为我是 html 和 phonegap 的新手,所以我不知道程序,请帮助我。
这是我的java代码
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
Button addImage = (Button) findViewById(R.id.send);
addImage.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
GMailSender mailsender = new GMailSender("xya@gmail.com", "pw123");
String[] toArr = { "abc@gmail.com", "efg@gmail.com" };
mailsender.set_to(toArr);
mailsender.set_from("sender@gmail.com");
mailsender.set_subject("This is an email sent using my Mail JavaMail wrapper from an Android device.");
mailsender.setBody("Email body.");
try {
//mailsender.addAttachment("/sdcard/filelocation");
if (mailsender.send()) {
Toast.makeText(MainActivity.this,
"Email was sent successfully.",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MainActivity.this, "Email was not sent.",
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Log.e("MailApp", "Could not send email", e);
}
}
});
}
html代码
<body >
<button onclick=" " id="email">Send_Email </button>
</body>