我想使用此代碼上傳圖片文件:未知異常,同時試圖上傳圖像解析
if (mMediaUri != null){
Log.v("url = "+mMediaUri, "");
//create parse object for image to upload
final ParseObject imageUpload = new ParseObject("TestNotes");
try {
//convert image to bytes for upload.
byte[] fileBytes = FileHelper.getByteArrayFromFile(getContext(), mMediaUri);
if (fileBytes == null) {
//there was an error
Toast.makeText(getContext(), "There was an error. Try again!", Toast.LENGTH_LONG).show();
} else {
fileBytes = FileHelper.reduceImageForUpload(fileBytes);
String fileName = FileHelper.getFileName(getContext(), mMediaUri, "image");
final ParseFile file = new ParseFile(fileName, fileBytes);
imageUpload.saveEventually(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
imageUpload.put("File", file);
sendNote.saveInBackground();
imageUpload.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
Toast.makeText(getContext(), "Success Uploading iMage!", Toast.LENGTH_LONG).show();
}
});
} else {
//there was an error
//there was an error
Log.v(""+e.getMessage(), " Error Here");
Toast.makeText(getContext(), "Error", Toast.LENGTH_LONG).show();
}
}
});
}
} catch (Exception e1) {
Toast.makeText(getContext(), "Our Error", Toast.LENGTH_LONG).show();
Log.v("our Error = "+ e1.getMessage(),"");
Toast.makeText(getContext(), e1.getMessage(), Toast.LENGTH_LONG).show();
}
,但它不工作我得到exception
和我試過了TI弄清楚什麼exception
是,但其未展示在此行中我logcat
,甚至在我Toast
我得到任何的異常:
} catch (Exception e1) {
Toast.makeText(getContext(), "Our Error", Toast.LENGTH_LONG).show();
Log.v("our Error = "+ e1.getMessage(),"");
Toast.makeText(getContext(), e1.getMessage(), Toast.LENGTH_LONG).show();
}
我不知道爲什麼它顯示我的只有這吐司
Toast.makeText(getContext(), "Our Error"
任何想法可能是例外,爲什麼我不能夠看到它在我的logcat或吐司?或者我的方法做錯了什麼?而mMdeiaUri
是Uri
的圖片,
謝謝!爲使任何指導的權利會因此有助於在日誌調用我
我得到這樣的:
01-27 00:51:43.799 2805-2805/pb.pocketboard I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
01-27 00:51:43.799 2805-2805/pb.pd W/dalvikvm: VFY: unable to resolve virtual method 455: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
01-27 00:51:43.799 2805-2805/pb.pd D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
01-27 00:51:43.799 2805-2805/pb.pd I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
01-27 00:51:43.799 2805-2805/pb.pd W/dalvikvm: VFY: unable to resolve virtual method 457: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
01-27 00:51:43.799 2805-2805/pb.pd D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
因爲您將所有消息都分配給第一個參數,所以在詳細信道中不會看到任何內容。嘗試Log.v(「我們的錯誤」,e1.getMessage())。 – natario
感謝您的回覆@mvai讓我試試這個 –
@mvai請看看我更新的問題,我面臨這個Log.v問題一會兒,他們甚至沒有打印任何東西,即使按照您的建議嘗試 –