Code example for MediaScannerConnection

Methods: disconnect

0
 
    private void scanForGallery(Uri newImage) {
        this.scanMe = newImage;
        if(this.conn != null) {
            this.conn.disconnect();
        } 
        this.conn = new MediaScannerConnection(this.cordova.getActivity().getApplicationContext(), this);
        conn.connect();
    } 
 
    public void onMediaScannerConnected() { 
        try{ 
            this.conn.scanFile(this.scanMe.toString(), "image/*");
        } catch (java.lang.IllegalStateException e){
            LOG.e(LOG_TAG, "Can't scan file in MediaScanner after taking picture");
        } 
 
    } 
 
    public void onScanCompleted(String path, Uri uri) {
        this.conn.disconnect();