Сохранить изображения Gif в галерее с помощью кода? - PullRequest
0 голосов
/ 11 ноября 2019

Я хочу сохранить изображения Gif в галерее в Android. Я много раз пытался сохранить GIF в галерее, но когда я нажимаю кнопку «Сохранить», он загружается, но не в формате GIF. Я не знаю, в чем проблема.

Плз, помогите мне решить эту проблему

public void saveImageToExternal(String imgName, Bitmap bm) throws IOException {
        //Create Path to save Image
        File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES + "/savaimage1.gif"); //Creates app specific folder
        path.mkdirs();
        File imageFile = new File(path, imgName + ".gif");// Imagename.png

        Log.e("msg", imageFile.toString());

        FileOutputStream out = new FileOutputStream(imageFile);
        Toast.makeText(this, "save", Toast.LENGTH_SHORT).show();
        try {
             bm.compress(Bitmap.CompressFormat.PNG, 100, out); // Compress Image

            out.flush();
            out.close();

            // Tell the media scanner about the new file so that it is
            // immediately available to the user.
            MediaScannerConnection.scanFile(MainActivity.this, new String[]{imageFile.getAbsolutePath()}, null, new MediaScannerConnection.OnScanCompletedListener() {
                public void onScanCompleted(String path, Uri uri) {
                    Log.i("ExternalStorage", "Scanned " + path + ":");
                    Log.i("ExternalStorage", "-> uri=" + uri);
                }
            });
        } catch (Exception e) {
            throw new IOException();
        }
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...