2

你好,我建立了一個Android應用程序,它使用相機拍照,然後將其作爲電子郵件附件發送。Android製作照片,然後在三星手機上發送附件

它在HTC手機上的工作很好,但它不能在三星Galaxy上發揮作用,它只向我的郵件發送一個空的附件。

有人有建議如何解決這個問題嗎?

我的代碼:

private final static int TAKE_PHOTO_CODE = 1; 
File downloadedPic = null; 
Intent in; 
boolean taken = false; 

//NEW 
private static int TAKE_PICTURE = 1; 
private Uri outputFileUri; 


    private void TakePhoto() { 
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
    File file = new File( 
      Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "fotowedstrijd.jpeg"); 
    outputFileUri = Uri.fromFile(file); 
    intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); 
    startActivityForResult(intent, TAKE_PICTURE); 
} 

private void sendPhoto(){ 
Intent picMessageIntent = new Intent(Intent.ACTION_SEND); 
picMessageIntent.putExtra(Intent.EXTRA_EMAIL , new String[]{"[email protected]"}); //[email protected] 
picMessageIntent.putExtra(Intent.EXTRA_SUBJECT, "Fotowedstrijd inzending Openbedrijvendag Emmen"); 
picMessageIntent.putExtra(Intent.EXTRA_TEXT , "Mijn inzending voor de fotowedstrijd"); 
picMessageIntent.setType("image/jpeg"); 
File downloadedPic = new File( 
    Environment.getExternalStoragePublicDirectory( 
    Environment.DIRECTORY_PICTURES), 
    "fotowedstrijd.jpeg"); 
picMessageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic)); 
startActivity(picMessageIntent); 
//startActivity(Intent.createChooser(picMessageIntent, "Send your picture using:")); 
} 
+0

我遇到了同樣的問題。 Gmail客戶端發送附件,但三星電子郵件客戶端不。你有沒有設法解決這個問題? –

+0

之後刪除文件嗎?也許在onActivityResult上。我正在保存該文件的緩存版本,並在共享後將其刪除並導致問題。顯然,電子郵件客戶端並不搶在那一刻的形象,但後來(一旦該文件已被刪除) –

+0

我有同樣的問題,samsungs電子郵件客戶端沒有設法解決這個:(我沒有刪除剩下的文件它在緩存中 – ddnl

回答

1

我發現了什麼: Android ACTION_IMAGE_CAPTURE Intent

它說的是,有可能與MediaStore.ACTION_IMAGE_CAPTURE的錯誤。

還有其他的東西出現在我的腦海裏: 也許這個目錄不存在於你的三星手機上,所以你必須先創建它。

只是一些第一次猜測。

1

請把我的提取碼一看,我曾經在我的三星Galaxy S2相同的問題,如:

  1. 我使用三星Galaxy S2,我不能提上了attachement照片電子郵件客戶端,所以我複製了另一個只爲三星製作了教程的代碼,並且它可以工作。

  2. 當我選擇通過默認的電子郵件客戶端發送電子郵件,即三星有,它的應用程序崩潰,但是當我從它的Gmail郵件客戶端發送它的作品。

我的代碼是在這裏:Android take photo and send it as an attachment to an email, imageview reset on rotation

的onActivityResult方法中我檢查相機的requestcode和我加載了我送的照片,上ImageView的,在那之後很容易把它作爲附件(我在電子郵件()方法上執行此操作)。

相關問題