android.content.Intent#ACTION_ATTACH_DATA源码实例Demo

下面列出了android.content.Intent#ACTION_ATTACH_DATA 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Camera-Roll-Android-App   文件: ItemActivity.java
public void setPhotoAs() {
    if (!(albumItem instanceof Photo)) {
        return;
    }

    Uri uri = albumItem.getUri(this);

    Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
    intent.setDataAndType(uri, MediaType.getMimeType(this, uri));
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    try {
        startActivityForResult(Intent.createChooser(intent,
                getString(R.string.set_as)), 13);
    } catch (SecurityException se) {
        Toast.makeText(this, "Error (SecurityException)", Toast.LENGTH_SHORT).show();
        se.printStackTrace();
    } catch (ActivityNotFoundException anfe) {
        Toast.makeText(this, "No App found", Toast.LENGTH_SHORT).show();
        anfe.printStackTrace();
    }
}
 
源代码2 项目: DelegateAdapter   文件: PhotoActivity.java
public void onSetFabClick(View view) {
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
            == PackageManager.PERMISSION_GRANTED) {
        if (mFile != null && mFile.exists()) {
            Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
            intent.addCategory(Intent.CATEGORY_DEFAULT);
            intent.setDataAndType(Uri.fromFile(mFile), "image/jpeg");
            intent.putExtra("mimeType", "image/jpeg");
            this.startActivity(Intent.createChooser(intent, "Set as:"));
            return;
        }
        if (mService != null) {
            if (isDownloading) {
                ToastCenter.with(PhotoActivity.this).text(R.string.toast_download_is_executing).showShort();
                return;
            }
            download();
        } else {
            bindStreamService();
        }
    } else {
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 100);
    }

}
 
源代码3 项目: Mysplash   文件: DownloadHelper.java
private void wallpaperDownloadSuccess(DownloadMissionEntity entity) {
    // Uri file = Uri.parse("file://" + entity.getFilePath());
    Uri file = FileUtils.filePathToUri(context, entity.getFilePath());
    Intent action = new Intent(Intent.ACTION_ATTACH_DATA);
    action.setDataAndType(file, "image/jpg");
    action.putExtra("mimeType", "image/jpg");
    Mysplash.getInstance()
            .getTopActivity()
            .startActivity(
                    Intent.createChooser(
                            action,
                            Mysplash.getInstance()
                                    .getString(R.string.feedback_choose_wallpaper_app)));
}
 
源代码4 项目: droidddle   文件: Util.java
public static Intent createSetAsIntent(IImage image) {
    Uri u = image.fullSizeImageUri();
    Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
    intent.setDataAndType(u, image.getMimeType());
    intent.putExtra("mimeType", image.getMimeType());
    return intent;
}
 
源代码5 项目: MoeGallery   文件: MainActivity.java
void setWallpaper() {
    Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setDataAndType(currentImageUri, "image/*");
    intent.putExtra("mimeType", "image/*");
    this.startActivity(Intent.createChooser(intent, getResources().getString(R.string.set_as)));
}
 
源代码6 项目: reader   文件: Util.java
public static Intent createSetAsIntent(IImage image) {
    Uri u = image.fullSizeImageUri();
    Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
    intent.setDataAndType(u, image.getMimeType());
    intent.putExtra("mimeType", image.getMimeType());
    return intent;
}
 
源代码7 项目: reader   文件: Util.java
public static Intent createSetAsIntent(IImage image) {
    Uri u = image.fullSizeImageUri();
    Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
    intent.setDataAndType(u, image.getMimeType());
    intent.putExtra("mimeType", image.getMimeType());
    return intent;
}
 
源代码8 项目: android-imageviewer   文件: ImageViewerActivity.java
public void doSettings() {
    if (!TextUtils.isEmpty(imageUri)) {
        Uri uri = Uri.parse(imageUri);
        Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
        intent.setDataAndType(uri, "image/jpg");
        intent.putExtra("mimeType", "image/jpg");
        startActivityForResult(Intent.createChooser(intent, getText(R.string.action_settings)), 200);
    }
}
 
源代码9 项目: actor-platform   文件: Intents.java
public static Intent setAsAvatar(FileReference location) {
    Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
    intent.setDataAndType(getAvatarUri(location), "image/jpg");
    intent.putExtra("mimeType", "image/jpg");
    return intent;
}
 
 方法所在类
 同类方法