Java Code Examples for android.content.Intent#ACTION_ATTACH_DATA

The following examples show how to use android.content.Intent#ACTION_ATTACH_DATA . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
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();
    }
}
 
Example 2
Source Project: DelegateAdapter   File: PhotoActivity.java    License: Apache License 2.0 6 votes vote down vote up
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);
    }

}
 
Example 3
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)));
}
 
Example 4
Source Project: droidddle   File: Util.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 5
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)));
}
 
Example 6
Source Project: reader   File: Util.java    License: MIT License 5 votes vote down vote up
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;
}
 
Example 7
Source Project: reader   File: Util.java    License: MIT License 5 votes vote down vote up
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;
}
 
Example 8
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);
    }
}
 
Example 9
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;
}