[英]Android volley to upload image
我按照本教程將圖像上傳到服務器。 但是,一旦我單擊圖庫中的圖片之一,它就會關閉我的應用程序。 我有兩個按鈕,一個在用戶選擇后瀏覽,另一個在上載。 要瀏覽,我做:
private void showFileChooser() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
}
為了得到結果,我重寫:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
Uri filePath = data.getData();
try {
//Getting the Bitmap from Gallery
bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), filePath);
//Setting the Bitmap to ImageView
imageView.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
}
}
LogCat錯誤
01-06 17:32:02.937 24999-24999/? D/dalvikvm: Late-enabling CheckJNI
01-06 17:32:03.148 24999-24999/com.mypackage I/Adreno-EGL: <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018_msm8226_LNX.LA.3.5.1_RB1__release_AU ()
OpenGL ES Shader Compiler Version: E031.24.00.08
Build Date: 03/07/14 Fri
Local Branch:
Remote Branch: quic/LNX.LA.3.5.1_RB1.1
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018 + f2fd134 + NOTHING
01-06 17:32:03.176 24999-24999/com.mypackage D/OpenGLRenderer: Enabling debug mode 0
01-06 17:32:21.603 24999-24999/com.mypackage W/IInputConnectionWrapper: showStatusIcon on inactive InputConnection
我解決了 我有
android:noHistory="true"
在執行登錄操作的同一活動中,后來我改變了主意,想徹底更改體系結構,卻忘記刪除該行或將其設置為假。 因此,當我從圖庫中獲得結果時,活動便從堆棧中消失了。 現在,我刪除了所有它應有的狀態。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.