The application has its own gallery, but I can not select a picture in it through ACTION_GET_CONTENT. The gallery starts, but when you click on a picture, nothing happens, the android monitor is silent. In other galleries, the picture is selected. As it seems to me, my gallery does not transmit the URI of the picture. What is the problem? Where am I stupid? Code below

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.safr); sp = getSharedPreferences("resume", MODE_PRIVATE); Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(intent, SELECT_PICTURE); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { if (requestCode == SELECT_PICTURE) { Uri selectedImageUri = data.getData(); selectedImagePath = getPath(selectedImageUri); try { FileInputStream fileis=new FileInputStream(selectedImagePath); BufferedInputStream bufferedstream=new BufferedInputStream(fileis); byte[] bMapArray= new byte[bufferedstream.available()]; bufferedstream.read(bMapArray); if (fileis != null) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_STREAM, selectedImageUri); startActivityForResult(Intent.createChooser(intent, ""), SELECT_PICTURE); } if (bufferedstream != null) { bufferedstream.close(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } } public String getPath(Uri uri) { String[] projection = { MediaStore.Images.Media.DATA }; Cursor cursor = managedQuery(uri, projection, null, null, null); int column_index = cursor .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } 

Gallery is a GridView, adapter code

 public class Adapter extends ArrayAdapter<File> { LayoutInflater mInflater; Picasso mPicasso; private static final String TAG = "myLogs"; public Adapter(Context context, File[] objects) { super(context, R.layout.list_item, objects); mInflater = LayoutInflater.from(context); mPicasso = Picasso.with(context); } @Override public View getView ( final int position, View convertView, ViewGroup parent){ View view = convertView; if (view == null) { view = mInflater.inflate(R.layout.list_item, parent, false); } ImageView imageView = (ImageView) view.findViewById(R.id.imageView); mPicasso.load(getItem(position)).fit().centerCrop().into(imageView); return view; } 

}

Manifesto

 <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.GET_CONTENT" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.OPENABLE" /> <data android:mimeType="image/*" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.PICK"/> <category android:name="android.intent.category.DEFAULT"/> <data android:mimeType="image/*"/> </intent-filter> 
  • one
    you need to show at what stage the error, and the intent-filter of the component you are trying to work with, after the call. - Shwarz Andrei
  • edited - evb

0