2012-02-02 25 views
0

私のアプリケーションから添付された電子メールを送信するためにDroid Xの電話に問題があります。私のコードは他のすべてのAndroidデバイスでうまくいきます。HTC、Samsung galaxy、Milestoneのように。しかし、私はドロイドXだけに問題があります。私はsdcardに自分のhtmlファイルを保存しましたが、電子メールに添付することはできません。私は空のメールを受け取りました、私はドロイドxモバイルで添付ファイルを取得しませんでした。 ここで私は、SDカード内のファイルの保存...Driod X送信添付ファイル電子メール

を自分のコードを添付:

添付ファイル付きのメールを送信
protected void savehtml(HtmlViwer htmlViwer, String htmlcontent2,String string) { 
    try { 
     File root = new File(Environment.getExternalStorageDirectory(),"PalmAgent"); 
     if (!root.exists()) { 
      root.mkdirs(); 
     } 
     String sdcardhtmlpath = root.getPath().toString() + "/print.html"; 
     FileWriter fstream = new FileWriter(sdcardhtmlpath); 
     BufferedWriter out = new BufferedWriter(fstream); 

     out.write(htmlcontent2); 
     out.close(); 
     } catch (Exception e) {// Catch exception if any 

     System.err.println("Error: " + e.getMessage()); 
    } 
} 

:に接続中

Intent sentinIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); 
    sentinIntent.setType("plain/text"); 
    ArrayList<Uri> uris = new ArrayList<Uri>(); 

    File root = new ile(Environment.getExternalStorageDirectory(), "PalmAgent"); 
    String sdcardhtmlpath = root.getPath().toString()+ "/print.html"; 
    String[] filePaths = new String[] { sdcardhtmlpath }; 

     for (String file : filePaths) { 
      File fileIn = new File(file); 
      Uri u = Uri.fromFile(fileIn); 
      uris.add(u); 
    } 
     sentinIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); 
     startActivity(Intent.createChooser(sentinIntent,"Send mail via")); 
} 

答えて

2

は、最後に私が...解決策を見つけましたPCのsdcardはその時間をsdcardにアクセスできないようにPCとメモリを共有します。また、同じデバイスにはメモリカードが付いていません。

Intent sentinIntent = new Intent(Intent.ACTION_SEND); 
sentinIntent.setType("plain/text"); 


File root = new ile(Environment.getExternalStorageDirectory(), "Path"); 
String sdcardhtmlpath = root.getPath().toString()+ "/print.html"; 
String[] filePaths = new String[] { sdcardhtmlpath }; 

    uris = getURI(filePaths); 
    sentinIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); 
    startActivity(Intent.createChooser(sentinIntent,"Send mail via")); 
} 
関連する問題