I am working on Wallpaper app, in which user can set wallpaper and share that wallpaper also via bluetooth, and other apps also. I have used following to identify user selected wallpaper.
ImageView imagePreview = (ImageView) findViewById(R.id.iv_preview);
imagePreview.setTag("a1");
And used getTag()
in my another function to use that selected wallpaper.
To share the user selected image i have used following code
String mDrawableName = (String) imagePreview.getTag();
Uri imageUri = Uri.parse("android.resource://com.mypackage.wallpaperapp/drawable/"+mDrawableName);
Log.d("here i got", imageUri.toString()); // here i got android.resource://com.mypackage.wallpaperapp/drawable/a3
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
shareIntent.setType("image/*");
startActivity(Intent.createChooser(shareIntent, "Share From"));
But i am getting the the error in device that " file unknown file cannot send", Where am i wrong here?
I found in some stuff that i have to firstly save my image resource into storage and after that i can send my image. But i dont know how can i save my image resource file into storage and send it to via different apps.
Please Help.