Невозможно поделиться изображением с помощью метода Createchooser - PullRequest
0 голосов
/ 04 марта 2019

Я работаю над извлечением изображения из SQLite и передачей его с помощью метода CreateChooser, метод работает корректно с текстом, но не с изображением.

Cursor cursor=sqLiteHelper.getData();
cursor.moveToFirst();
byte[] image= cursor.getBlob(cursor.getColumnIndex("pic"));

Bitmap bmp = BitmapFactory.decodeByteArray(image, 0, image.length);
imageView2.setImageBitmap(bmp);
        Toast.makeText(getApplicationContext(),"added",Toast.LENGTH_SHORT).show();

Intent shareintent=new Intent (Intent.ACTION_SEND);
shareintent.setType("image/*");
ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.JPEG,100,byteArrayOutputStream);
File file =new File(Environment.getExternalStorageDirectory()+File.separator+"ImageDemo.jpg");
        try{
            file.createNewFile();
            FileOutputStream fileOutputStream=new FileOutputStream(file);
            fileOutputStream.write(byteArrayOutputStream.toByteArray());

        }catch (IOException e) {
            e.printStackTrace();
        }
        shareintent.putExtra(Intent.EXTRA_TEXT,"abc");
        shareintent.putExtra(Intent.EXTRA_STREAM,Uri.parse("content://sdcard/ImageDemo.ipt"));
        shareintent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        startActivity(Intent.createChooser(shareintent,"Share image to "));

И появляется предупреждающее сообщение:

W/CursorWindow: Window is full: requested allocation 629733 bytes, free space 207476 bytes, window size 2097152 bytes    
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
W/System: A resource failed to call close.

Пожалуйста, кто-нибудь может сказать мне, что не так с моим кодом?Я пытался поделиться им с Gmail и Twitter, и ни один из них не сработал. Спасибо

...