((HomeActivity) getActivity()).contactus
.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
sendEmail();
}
});
((HomeActivity) getActivity()).attachmentimageview
.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(
Intent.createChooser(intent, "Complete action using"),
MY_INTENT_CLICK);
}
});
return view;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == MY_INTENT_CLICK) {
if (null == data)
return;
String selectedImagePath;
Uri selectedImageUri = data.getData();
// MEDIA GALLERY
selectedImagePath = ImageFilePath.getPath(
getActivity(), selectedImageUri);
Log.i("Image File Path", "" + selectedImagePath);
// txta.setText("File Path : \n" + selectedImagePath);
}
}
}
private void sendEmail() {
try {
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
String[] recipients = new String[] { "Enter email" };
emailIntent
.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
emailIntent
.putExtra(
Intent.EXTRA_EMAIL,
new String[] { "[email protected],[email protected]" });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Feedback");
emailIntent.putExtra(Intent.EXTRA_STREAM, selectedImagePath);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
Html.fromHtml(""));
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "HI"
+ "\n\n" + contactustext.getText().toString());
emailIntent.setType("message/rfc822");
startActivity(emailIntent);
} catch (Exception e) {
e.printStackTrace();
}
}
這是我的代碼,我想我使用給定的代碼,我能夠從廚房拿到路徑從SD卡或畫廊附加文件附加在Android的文件但是,當我在與我們聯繫按鈕則點擊如果我們不使用附件,那麼它與文本正常工作相同的工作,以獲得文件目錄,請檢查哪裏做錯了,如何解決它,請建議我actully我想發送一些文本,並附件發送通過Gmail時,當我點擊按鈕聯繫我們它重定向到附件和文本到Gmail,然後我們可以發送它。如何使用Gmail
什麼xmlFilename名字? – user1340963 2015-04-06 09:02:01
文件的名稱。 – 2015-04-06 09:09:14
請檢查我的代碼我正在做同樣的事情但問題來了附件按鈕和發送按鈕都表現得像這一樣請檢查並編輯我的代碼 – user1340963 2015-04-06 09:13:20