当前位置: 首页>>代码示例>>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;未经允许,请勿转载。