当前位置: 首页>>代码示例>>Java>>正文


Java WindowAndroid.sendBroadcast方法代码示例

本文整理汇总了Java中org.chromium.ui.WindowAndroid.sendBroadcast方法的典型用法代码示例。如果您正苦于以下问题:Java WindowAndroid.sendBroadcast方法的具体用法?Java WindowAndroid.sendBroadcast怎么用?Java WindowAndroid.sendBroadcast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.chromium.ui.WindowAndroid的用法示例。


在下文中一共展示了WindowAndroid.sendBroadcast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onIntentCompleted

import org.chromium.ui.WindowAndroid; //导入方法依赖的package包/类
/**
 * Callback method to handle the intent results and pass on the path to the native
 * SelectFileDialog.
 * @param window The window that has access to the application activity.
 * @param resultCode The result code whether the intent returned successfully.
 * @param contentResolver The content resolver used to extract the path of the selected file.
 * @param results The results of the requested intent.
 */
@Override
public void onIntentCompleted(WindowAndroid window, int resultCode,
        ContentResolver contentResolver, Intent results) {
    if (resultCode != Activity.RESULT_OK) {
        onFileNotSelected();
        return;
    }
    boolean success = false;
    if (results == null) {
        // If we have a successful return but no data, then assume this is the camera returning
        // the photo that we requested.
        nativeOnFileSelected(mNativeSelectFileDialog, mCameraOutputUri.getPath());
        success = true;

        // Broadcast to the media scanner that there's a new photo on the device so it will
        // show up right away in the gallery (rather than waiting until the next time the media
        // scanner runs).
        window.sendBroadcast(new Intent(
                Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, mCameraOutputUri));
    } else {
        // We get back a content:// URI from the system if the user picked a file from the
        // gallery. The ContentView has functionality that will convert that content:// URI to
        // a file path on disk that Chromium understands.
        Cursor c = contentResolver.query(results.getData(),
                new String[] { MediaStore.MediaColumns.DATA }, null, null, null);
        if (c != null) {
            if (c.getCount() == 1) {
                c.moveToFirst();
                String path = c.getString(0);
                if (path != null) {
                    // Not all providers support the MediaStore.DATA column. For example,
                    // Gallery3D (com.android.gallery3d.provider) does not support it for
                    // Picasa Web Album images.
                    nativeOnFileSelected(mNativeSelectFileDialog, path);
                    success = true;
                }
            }
            c.close();
        }
    }
    if (!success) {
        onFileNotSelected();
        window.showError(R.string.opening_file_error);
    }
}
 
开发者ID:openresearch,项目名称:android-chromium-view,代码行数:54,代码来源:SelectFileDialog.java


注:本文中的org.chromium.ui.WindowAndroid.sendBroadcast方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。