Java Code Examples for android.content.Intent#ACTION_ATTACH_DATA

The following examples show how to use android.content.Intent#ACTION_ATTACH_DATA . 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
Source File: ItemActivity.java    From Camera-Roll-Android-App with Apache License 2.0 6 votes vote down vote up
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 File: PhotoActivity.java    From DelegateAdapter with 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
Source File: DownloadHelper.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 File: Util.java    From droidddle with 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
Source File: MainActivity.java    From MoeGallery with GNU General Public License v3.0 5 votes vote down vote up
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 File: Util.java    From reader with 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 File: Util.java    From reader with 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
Source File: ImageViewerActivity.java    From android-imageviewer with Apache License 2.0 5 votes vote down vote up
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
Source File: Intents.java    From actor-platform with GNU Affero General Public License v3.0 4 votes vote down vote up
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;
}