Java 单击按钮时直接指向android邮件客户端
嗨 这是ListView的单个项目视图。我不想去看电子邮件 单击下面片段中的按钮时客户端有一封电子邮件 解析数据库中的列。当点击按钮时,它将导致 使用此单一项目视图的特定电子邮件id的电子邮件客户端 我试过一些代码它不起作用任何人请帮助Java 单击按钮时直接指向android邮件客户端,java,android,listview,parse-server,Java,Android,Listview,Parse Server,嗨 这是ListView的单个项目视图。我不想去看电子邮件 单击下面片段中的按钮时客户端有一封电子邮件 解析数据库中的列。当点击按钮时,它将导致 使用此单一项目视图的特定电子邮件id的电子邮件客户端 我试过一些代码它不起作用任何人请帮助 import android.content.*; import android.graphics.*; import android.net.*; import android.os.Bundle; import android.support.design.
import android.content.*;
import android.graphics.*;
import android.net.*;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.*;
import android.view.View;
import android.widget.*;
import com.parse.*;
import com.parse.ParseException;
import com.squareup.picasso.*;
import java.io.*;
import java.net.*;
public class SingleItemView extends AppCompatActivity {
String objectId;
protected TextView txtv;
protected TextView txtv1;
protected ImageView txtv2;
protected ImageView txtv3;
Button sendEmail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_item_view);
txtv =(TextView)findViewById(R.id.txt123);
txtv1 =(TextView)findViewById(R.id.txt1234);
txtv2 =(ImageView)findViewById(R.id.txt12345);
txtv3 =(ImageView)findViewById(R.id.txt123456);
Intent i =getIntent();
objectId = i.getStringExtra("objectId");
ParseQuery<ParseObject> query = ParseQuery.getQuery("_User");
query.getInBackground(objectId, new GetCallback<ParseObject>() {
public void done(ParseObject object, ParseException e) {
if (e == null) {
String username = object.getString("firstname");
txtv.setText(username);
String position = object.getString("position");
txtv1.setText(position);
URL url = null;
try {
url = new URL("http://izi-dev.fr/fbc/assets/uploads/" + object.getString("image"));
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
Bitmap bmp = null;
try {
bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch (IOException e1) {
e1.printStackTrace();
}
txtv2.setImageBitmap(bmp);
URL url1 = null;
try {
url = new URL("http://izi-dev.fr/fbc/assets/uploads/" + object.getString("image"));
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
Bitmap bmp1 = null;
try {
bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch (IOException e1) {
e1.printStackTrace();
}
txtv3.setImageBitmap(bmp);
} else {
// something went wrong
}
}
});
sendEmail = (Button) findViewById(R.id.button5);
sendEmail.setOnClickListener((View.OnClickListener) this);
}
public void onClick(View v) {
try{
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL , "email");
emailIntent.setType("text/plain"); // <-- HERE
startActivity(emailIntent); // <-- AND HERE
}finally {
}
}
}
导入android.content.*;
导入android.graphics.*;
导入android.net。*;
导入android.os.Bundle;
导入android.support.design.widget.FloatingActionButton;
导入android.support.design.widget.Snackbar;
导入android.support.v7.app.AppActivity;
导入android.support.v7.widget.Toolbar;
导入android.util.*;
导入android.view.view;
导入android.widget.*;
导入com.parse.*;
导入com.parse.ParseException;
导入com.squareup.picasso.*;
导入java.io.*;
导入java.net。*;
公共类SingleItemView扩展了AppCompatActivity{
字符串objectId;
受保护的文本视图txtv;
受保护的文本视图txtv1;
受保护的ImageView txtv2;
受保护的ImageView txtv3;
按钮发送电子邮件;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u single\u item\u视图);
txtv=(TextView)findViewById(R.id.txt123);
txtv1=(TextView)findViewById(R.id.txt1234);
txtv2=(ImageView)findViewById(R.id.txt12345);
txtv3=(ImageView)findViewById(R.id.txt123456);
Intent i=getIntent();
objectId=i.getStringExtra(“objectId”);
ParseQuery=ParseQuery.getQuery(“_User”);
getInBackground(objectId,newgetcallback(){
公共无效完成(ParseObject对象,parsee异常){
如果(e==null){
字符串用户名=object.getString(“firstname”);
txtv.setText(用户名);
字符串位置=object.getString(“位置”);
txtv1.setText(位置);
URL=null;
试一试{
url=新url(“http://izi-dev.fr/fbc/assets/uploads/“+object.getString(“image”);
}捕获(格式错误的异常e1){
e1.printStackTrace();
}
位图bmp=null;
试一试{
bmp=BitmapFactory.decodeStream(url.openConnection().getInputStream());
}捕获(IOE1异常){
e1.printStackTrace();
}
txtv2.setImageBitmap(bmp);
URL url1=null;
试一试{
url=新url(“http://izi-dev.fr/fbc/assets/uploads/“+object.getString(“image”);
}捕获(格式错误的异常e1){
e1.printStackTrace();
}
位图bmp1=null;
试一试{
bmp=BitmapFactory.decodeStream(url.openConnection().getInputStream());
}捕获(IOE1异常){
e1.printStackTrace();
}
设置图像位图(bmp);
}否则{
//出了点问题
}
}
});
sendEmail=(按钮)findViewById(R.id.button5);
sendmail.setOnClickListener((View.OnClickListener)this);
}
公共void onClick(视图v){
试一试{
Intent emailIntent=新的Intent(android.content.Intent.ACTION\u SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL,“EMAIL”);
emailIntent.setType(“text/plain”);//您以错误的方式设置了单击侦听器
实现ClickListener
公共类SingleItemView扩展了AppCompatActivity实现视图。OnClickListener
设置侦听器
sendmail.setOnClickListener(此);
使用注释
@覆盖
单击“公共无效”(视图v)
请试试这个。试试这个:
sendEmail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(view.getId()==R.id.button5){
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ emailAddress });
i.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
i.putExtra(android.content.Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(i, "Send email"));
}
}
});
我可能正确地理解了你的问题,我建议你使用以下插件。基本上,通过这个插件,你只需点击一个按钮就可以发送HTML
cordova.plugins.email.open({
to: 'max@mustermann.de',
subject: 'Greetings',
body: '<h1>Nice greetings from Leipzig</h1>',
isHtml: true
});
cordova.plugins.email.open({
致:'max@mustermann.de',
主题:"问候",,
正文:“来自莱比锡的美好问候”,
isHtml:是的
});
请查看文档以了解更多信息。我希望我能帮助您。请查看此堆栈@Andreas Constantinou嗨,谢谢,我已经检查过了。但是无法连接按钮。当我尝试使用您的代码时,您能告诉我如何在我的代码中实现它(电子邮件地址、主题和文本)正在以红色显示。错误消息为无法解析symbol@FaizalMohamed您需要导入适当的对象。然后它们将不再是红色。@FaizalMohamed这只是模板。您必须用变量/值替换参数。哦,好的,thnks@Alvin Varghese我不解析任何数据,我只想在单击时转到邮件客户端,如果您可以致电how.hi,@Alvin Varghese请检查此项,如果您可以告诉我如何将解析数据库中的电子邮件列名实现为我的代码电子邮件列名为“email”hi,@jakubbialkowski。请检查此项,如果您可以支持解析中的电子邮件ID