Android 如何通过电子邮件共享以广告标题为主题、以广告描述为主体的广告
我是android新手。经过大量的搜索,我把这个问题贴在这里。我的应用程序包含在listview中显示的广告,我正在尝试通过电子邮件共享广告。我已经包含了电子邮件的代码,但它没有从SingleMenuItem.java活动中提取标题,将其显示在电子邮件的主题中,并将其描述显示在正文中。有人能帮我吗?下面是代码 Email.javaAndroid 如何通过电子邮件共享以广告标题为主题、以广告描述为主体的广告,android,json,Android,Json,我是android新手。经过大量的搜索,我把这个问题贴在这里。我的应用程序包含在listview中显示的广告,我正在尝试通过电子邮件共享广告。我已经包含了电子邮件的代码,但它没有从SingleMenuItem.java活动中提取标题,将其显示在电子邮件的主题中,并将其描述显示在正文中。有人能帮我吗?下面是代码 Email.java public class Email extends Activity { Button send; EditText address, subject
public class Email extends Activity {
Button send;
EditText address, subject, emailtext;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.email);
send=(Button ) findViewById(R.id.send);
address=(EditText) findViewById(R.id.emailaddress);
subject=(EditText) findViewById(R.id.emailsubject);
emailtext=(EditText) findViewById(R.id.emailtext);
send.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String []{ address.getText().toString()});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject.getText());
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, emailtext.getText());
Email.this.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
});
}
}
SingleMenuItemActivity.java
public class SingleMenuItemActivity extends Activity {
// JSON node keys
private static final String TAG_TITLE = "title";
private static final String TAG_DATE = "date";
private static final String TAG_NAME = "name";
private static final String TAG_CONTENT = "content";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.single_list_item);
// getting intent data
Intent in = getIntent();
// Get JSON values from previous intent
String title = in.getStringExtra(TAG_TITLE);
String date = in.getStringExtra(TAG_DATE);
String name = in.getStringExtra(TAG_NAME);
String content = in.getStringExtra(TAG_CONTENT);
// Displaying all values on the screen
TextView lblName = (TextView) findViewById(R.id.name_label);
TextView lblCost = (TextView) findViewById(R.id.email_label);
TextView lblDesc = (TextView) findViewById(R.id.mobile_label);
TextView lblCont = (TextView) findViewById(R.id.content_label);
lblName.setText(title);
lblCost.setText(date);
lblDesc.setText(name);
lblCont.setText(content);
final ImageView email3 = (ImageView) findViewById(R.id.email);
email3.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
//my codes
startActivity(new Intent(SingleMenuItemActivity.this, Email.class));
}
});
}
}
private void sendMail(字符串appName,字符串adLink){
String msg=“你好,
最近,我下载了”+appName+“”+
“从游戏商店。我发现这是一个非常具有挑战性和伟大的游戏。”+
“
我想向您推荐这个游戏。
”+
“
谢谢”;
String sub=“立即获取,它在Play Store中”;
意向电子邮件=新意向(意向.行动\发送);
email.setType(“text/html”);
email.putExtra(Intent.EXTRA_SUBJECT,sub);
email.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(msg));
email.setType(“message/rfc822”);
startActivity(Intent.createChooser(电子邮件,“选择电子邮件客户端:”);
}
在您的情况下,无需创建电子邮件。class
只需在单击email3
按钮的侦听器中编写您的电子邮件意图代码即可
代码应该如下所示
email3.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
//my codes
Intent emailIntent = Intent(android.content.Intent.ACTION_SENDTO);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, content));
startActivity(Intent.createChooser(emailIntent, "Email to Friend"));
}
});
消息正文应取自广告内容。bcoz广告不是固定的
email3.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
//my codes
Intent emailIntent = Intent(android.content.Intent.ACTION_SENDTO);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, content));
startActivity(Intent.createChooser(emailIntent, "Email to Friend"));
}
});