2017-05-01 7 views
-1

アンドロイドギャラリーにアクセスすることはできませんが、今、それは動作を停止しましたは、私はそれが働いていたギャラリーから画像を選択するためにこのコードを使用しています

(items[item].equals("Change from Library")) { 
         Intent i = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); 
         startActivityForResult(i, SELECT_FILE); 

onActivity結果。ここで私のAndroidの監視ログとき

Uri selectedImage = data.getData(); 
       String url = ""; 
       String pictureDirectoryPath= Functions.getRealPathFromURI(getActivity(),selectedImage()); 

画像ギャラリーを選択するボタンをクリックすると、

58.819 8995-8995/com.example.sharique.loginapp W/EGL_genymotion: eglSurfaceAttrib not implemented 
05-01 08:39:00.375 557-683/system_process W/InputMethodManagerService:  Window already focused, ignoring focus gain of:  [email protected] attribute=null,  token = [email protected] 
+0

thisのリンクを参照してください提供より良いエラーログ。 – DaAmidza

+0

また、すべての権限がありますか? – DaAmidza

+0

selectedImage uriが何らかの経路を指していると思うのはなぜですか? – Selvin

答えて

1
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); 
        photoPickerIntent.setType("image/*"); 
        startActivityForResult(photoPickerIntent, 500); 

は、あなたが要求許可コードを追加する必要があなたのターゲット場合

Uri selectedImageUri = imageReturnedIntent.getData(); 
String mPath = getPath(selectedImageUri); 

ある、getPath()メソッド

public String getPath(Uri uri) { 
     String[] projection = {MediaStore.MediaColumns.DATA}; 
     Cursor cursor = getActivity().managedQuery(uri, projection, null, null, null); 
     int column_index = cursor 
       .getColumnIndexOrThrow(MediaStore.MediaColumns.DATA); 
     cursor.moveToFirst(); 
     String imagePath = cursor.getString(column_index); 

     return cursor.getString(column_index); 
    } 

を招き、ロリポップよりも高いSDKをコンパイルonActivity

+0

あなたの ' getPath() 'メソッドは、アクセス権のないリムーバブルストレージ上のファイルへのパスなど、無駄な値を返します。 – CommonsWare

+0

haventヘルプが見つかりました:( – Shariq

関連する問題