How can I notify the gallery of a new image in android?

前端 未结 2 1125
轻奢々
轻奢々 2021-01-16 15:34

I have an android app that allows you to open an image on your phone using an intent to the Gallery. You make modifications to that image and the app saves it with a new na

相关标签:
2条回答
  • 2021-01-16 15:45

    use the MediaScannerConnection -

    MediaScannerConnection.scanFile(context,
        new String[] { imagePath }, null,
        new MediaScannerConnection.OnScanCompletedListener() {                      
            @Override
            public void onScanCompleted(String path, Uri uri) {
                //....                              
            }
        });
    
    0 讨论(0)
  • 2021-01-16 15:53

    As best I can tell from digging through the Android Camera app source, in the ActivityBase.java class there is an inner class called "MyAppBridge" which has the following comment:

    //////////////////////////////////////////////////////////////////////////
    //  The is the communication interface between the Camera Application and
    //  the Gallery PhotoPage.
    //////////////////////////////////////////////////////////////////////////
    

    Within that class there is a function as follows:

        public void addSecureAlbumItem(boolean isVideo, int id) {
            if (mServer != null) mServer.addSecureAlbumItem(isVideo, id);
        }
    

    Now the problem is trying to figure out where the Server class comes from, since searching the rest of the project doesn't turn anything up and I can't find it in the imports of the ActivityBase class.

    I know this isn't a complete answer but it should hopefully point you in the right direction. When in doubt: Use the source, Luke.

    0 讨论(0)
提交回复
热议问题