當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaScannerConnection.OnScanCompletedListener方法代碼示例

本文整理匯總了Java中android.media.MediaScannerConnection.OnScanCompletedListener方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaScannerConnection.OnScanCompletedListener方法的具體用法?Java MediaScannerConnection.OnScanCompletedListener怎麽用?Java MediaScannerConnection.OnScanCompletedListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.media.MediaScannerConnection的用法示例。


在下文中一共展示了MediaScannerConnection.OnScanCompletedListener方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: scanFile

import android.media.MediaScannerConnection; //導入方法依賴的package包/類
/**
 * 掃描指定的文件
 *
 * @param context
 * @param filePath
 * @param sListener
 */
public static MediaScannerConnection scanFile(Context context, String[] filePath, String[] mineType,
                                              MediaScannerConnection.OnScanCompletedListener sListener) {

    ClientProxy client = new ClientProxy(filePath, mineType, sListener);

    try {
        MediaScannerConnection connection = new MediaScannerConnection(
                context.getApplicationContext(), client);
        client.mConnection = connection;
        connection.connect();
        return connection;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:ceji-longquan,項目名稱:ceji_android,代碼行數:24,代碼來源:MediaScannerFile.java

示例2: onFileSaved

import android.media.MediaScannerConnection; //導入方法依賴的package包/類
private void onFileSaved(String filePath, int outputDestination) {
    String msg = String.format("File saved: %s", filePath);
    showToast(msg);
    Log.d(TAG, msg);

    MediaScannerConnection.OnScanCompletedListener scanListener = null;

    // if this is a share operation add post-scan listener to kick off share
    // listener is optional, not needed for export
    if (outputDestination == SaveImageService.INTENT_SHARE) {
        scanListener = mfileScanListener;
        mShareImagePath = filePath;
    }

    MediaScannerConnection.scanFile(this, new String[]{filePath}, null, scanListener);
}
 
開發者ID:debun8,項目名稱:texo,代碼行數:17,代碼來源:MainActivity.java

示例3: scanAndDeleteFile

import android.media.MediaScannerConnection; //導入方法依賴的package包/類
public static void scanAndDeleteFile(final Context context, final File file) {
    MediaScannerConnection.OnScanCompletedListener listener =
            new MediaScannerConnection.OnScanCompletedListener() {
                @Override
                public void onScanCompleted(String path, Uri uri) {
                    if (path == null)
                        return;

                    File scannedFile = new File(path);
                    if (scannedFile.equals(file)) {
                        //noinspection ResultOfMethodCallIgnored
                        file.delete();
                        MediaScannerConnection.scanFile(context, new String[]{file.getAbsolutePath()}, null, null);
                    }
                }
            };

    MediaScannerConnection.scanFile(context, new String[] { file.getAbsolutePath() }, null, listener);
}
 
開發者ID:msimonides,項目名稱:homerplayer,代碼行數:20,代碼來源:MediaScannerUtil.java

示例4: ClientProxy

import android.media.MediaScannerConnection; //導入方法依賴的package包/類
ClientProxy(String[] paths, String[] mimeTypes,
            MediaScannerConnection.OnScanCompletedListener client) {
    mPaths = paths;
    mMimeTypes = mimeTypes;
    mClient = client;
}
 
開發者ID:ceji-longquan,項目名稱:ceji_android,代碼行數:7,代碼來源:MediaScannerFile.java

示例5: scanSdCard

import android.media.MediaScannerConnection; //導入方法依賴的package包/類
public void scanSdCard(Context context, @Nullable MediaScannerConnection.OnScanCompletedListener listener) {
    MediaScannerConnection.scanFile(context, new String[]{Environment
            .getExternalStorageDirectory().getAbsolutePath()}, null, listener);

}
 
開發者ID:DuanJiaNing,項目名稱:Musicoco,代碼行數:6,代碼來源:MediaManager.java

示例6: scanFile

import android.media.MediaScannerConnection; //導入方法依賴的package包/類
public static void scanFile(String filePath, final String type, final MediaScannerConnection.OnScanCompletedListener listener) {

        String[] paths = new String[1];
        paths[0] = filePath;

        String[] mimeTypes = new String[1];
        mimeTypes[0] = type;

        MediaScannerConnection.scanFile(sContext, paths, mimeTypes, listener);
    }
 
開發者ID:sonyxperiadev,項目名稱:DroneControl,代碼行數:11,代碼來源:FTPConnectionTask.java

示例7: scanImage

import android.media.MediaScannerConnection; //導入方法依賴的package包/類
/**
 * 掃描多媒體文件
 *
 * @param context
 * @param filename
 * @param listener
 */
public static void scanImage(Context context, String filename, MediaScannerConnection.OnScanCompletedListener listener) {
    MediaScannerConnection.scanFile(context, new String[]{filename}, null, listener);
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:11,代碼來源:FileUtil.java


注:本文中的android.media.MediaScannerConnection.OnScanCompletedListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。