여기에 sdcard에서 이미지를 검색하고 이메일을 통해 보내는 코드입니다. 이미지와 함께 메일을 보내기위한 링크 아래에 사용됩니다 .... 희망은 유용합니다. 답장을 보내
protected final void onActivityResult(int requestCode, int
resultCode, final Intent i) {
super.onActivityResult(requestCode, resultCode, i);
if(resultCode == RESULT_OK){
// this matches the request code in the above call
if (requestCode == 1) {
Uri _uri = i.getData();
// this will be null if no image was selected...
if (_uri != null) {
// now we get the path to the image file
Cursor cursor = getContentResolver().query(_uri, null,
null, null, null);
cursor.moveToFirst();
int x=cursor.getInt(0);
// txtview.setText(imageFilePath);
int columnIndex = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
// Get image filename
imagePath = cursor.getString(columnIndex);
Log.d("Full Path",""+imagePath);
Toast.makeText(BrowsePicture.this, ""+imagePath, Toast.LENGTH_LONG).show();
File rootsd = Environment.getExternalStorageDirectory();
Log.d("abpath",""+rootsd.getAbsolutePath());
f= new File(imagePath);
Log.d("filename", f.getName());
// iv.setImageURI(Uri.withAppendedPath(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,""+ x));
iv.setImageURI(Uri.parse(imagePath));
cursor.close();
// here is the code sending mail
// **sendmail**(imagePath,f.getName());
progressDialog = ProgressDialog.show(this, "Please Wait...", "Sending Mail...",true);
thread = new Runnable() {
public void run() {
Log.d("Photo Image", "in thread");
// Toast.makeText(BrowsePicture.this, "in thread", Toast.LENGTH_SHORT).show();
sendmail(imagePath,f.getName());
}
};
t= new Thread(null, thread, "sending photo");
t.start();
}
}
}
}
또는 다른 방법
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
**startActivityForResult**(Intent.createChooser(intent,"Select Picture"), SELECT_PICTURE);
http://www.jondev.net/articles/Sending_Emails_without_User_Intervention_%28no_Intents%29_in_Android
는
http://davanum.wordpress.com/2007/12/22/android-send-email-via-gmail-actually-via-smtp/
감사합니다. 하지만 난 서버에서 이미지를 가져 가고 싶지 않아. 이미지를 동적으로 검색해야하며이를 공유하고 싶습니다. 메일에 이미지 이름이 있지만 attachment가 fails.im 인 Android TF101 장치를 사용하고 있습니다. 이걸 어떻게 풀어? – gowri
서버에서 이미지를 가져 오지는 않지만 sdcard (로컬 메모리 카드)에서 이미지를 가져 오는 중 ... –
http://www.jondev.net/articles/Sending_Emails_without_User_Intervention_%28no_Intents%29_in_Android 링크에서 사용할 수있는 라이브러리를 사용하셨습니까? 사용 된 이미지와 데이터로 메일을 보낼 수 있습니다. –