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

我怕爱的太早我们不能终老 提交于 2019-12-01 13:17:13

use the MediaScannerConnection -

MediaScannerConnection.scanFile(context,
    new String[] { imagePath }, null,
    new MediaScannerConnection.OnScanCompletedListener() {                      
        @Override
        public void onScanCompleted(String path, Uri uri) {
            //....                              
        }
    });

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!