如果用户单击操作设置 - 向开发人员发送电子邮件,则会弹出安装到用户设备的电子邮件应用程序。怎么做?
动作设置活动
package com.example.kristenungur.myapplication;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
public class SendEmailtoDev_activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sendemailtoappdev_layout);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_sendemail, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.SendEmail:
Intent intent = new Intent(SendEmailtoDev_activity.this, MainActivity.class);
startActivity(intent);
}
return super.onOptionsItemSelected(item);
}
}
答案 0 :(得分:1)
你可以这样做:
Intent emailFeedback = new Intent(Intent.ACTION_SEND);
emailFeedback.setType("text/email");
emailFeedback.putExtra(Intent.EXTRA_EMAIL, new String[] {"your_email_id_here"});
emailFeedback.putExtra(Intent.EXTRA_SUBJECT, "Feedback");
startActivity(Intent.createChooser(emailFeedback, "Send Feedback:"));
答案 1 :(得分:0)
好像我开始工作了。我将此添加到我的switch语句中,因此如果用户单击该名称,则会弹出电子邮件。那些使用IF语句的人,只需在switch语句中添加该语句即可。