我尝试以这种方式在电子邮件意图中附加多个文件(我在stackoverflow中接受的答案中看到):
String[] attachments;<--contains all the filenames i want to attach;
ArrayList<Uri> uris = new ArrayList<Uri>();
for (String file : attachments){
if(!file.equals("")){
Log.w("-"+file +"-","attached");
File fileIn = new File(file);
Uri u = Uri.fromFile(fileIn);
uris.add(u);
}
}
//check that uri list is correct
for(Uri uri1:uris){
Log.w(uri1.toString(),"uri list");
}
intMail.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
此代码导致Gmail客户端崩溃,logcat显示为警告:
Key android.intent.extra.STREAM expected Parcelable but value was a java.util.ArrayList.The default value <null> was returned.
之后,Gmal崩溃,logcat说
E/AndroidRuntime(10355): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.gm/com.google.android.gm.ComposeActivity}: java.lang.NullPointerException
我不知道我做错了什么......任何有用的建议/意见?