I'm working wallpaper application and having a problem with set wallpaper intent. I'm tried FileProvider, nothing changed.
My code showing this intent:
(1) https://i.ibb.co/RcW15qb/1.png
after select:
(2) https://i.ibb.co/nsQNvms/Screenshot-1568305811.png
but I want like this:
(3) https://i.ibb.co/F53p6sv/Screenshot-1568305398.png
fun setWallpaper (uri:Uri) {
val intent = Intent(Intent.ACTION_ATTACH_DATA)
intent.addCategory(Intent.CATEGORY_DEFAULT)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
intent.setDataAndType(uri, "image/*")
intent.putExtra("mimeType", "image/*")
startActivity(Intent.createChooser(intent, "Set as:"))}
I'm searched and tried smiliar set wallpaper intent example. Working but picture 1 and 2. I need intent like picture 3
Edit: I found but without scrolling and fixed options
val intent = Intent("android.service.wallpaper.CROP_AND_SET_WALLPAPER")
(4) https://i.ibb.co/H4vqdGF/Screenshot-1568315850.png
Related
Hi i have tried different ways to set my downloaded images from server as wallpaper using the native android intent in flutter but so far i am unable to implement it.
I have tried the intent package from pub.dev flutter but this code doesn't make my image pass through intent.
android_intent. Intent()
..setAction(android_action.Action.ATTACH_DATA)
..setData(outputFileUri)
//..putExtra(Extra.EXTRA_STREAM, outputFileUri)
..addFlag(1)
..setType('image/*')
..startActivity().catchError((e) => print(e));
Anyway to fix this would be really helpful. I am also sharing the functionality i want like in the image
t,
This should work for your situation:
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setDataAndType(uri, "image/*");
intent.putExtra("mimeType", "image/*");
this.startActivity(Intent.createChooser(intent, "Set as:"));
It's also independent of the image data type.
welcome everyone
I'm trying writing a program to set the wallpaper, lock screen and contact picture etc from imageView by action attach data or any other way of doing the same.
Please see the pictures
image 1
image2
some code :
Intent setAs = new Intent(Intent.ACTION_ATTACH_DATA);
setAs.setDataAndType(uri,"image/jpg");
setAs.putExtra("mimeType", "image/jpg");
startActivity(Intent.createChooser(setAs, "Set Image As"));
When the application runs out show me the message :
no app can perform this action
I add permission in manifest file :
<uses-permission android:name="android.permission.SET_WALLPAPER"></uses-permission>
Thank you very much for your time
I found solution , The cause of the problem is ( URI ) it should be this way :
Intent setAs = new Intent(Intent.ACTION_ATTACH_DATA);
// i : integer variable (index of array contains my images )
setAs.setDataAndType(Uri.parse(new File("/storage/emulated/0/pictures/wall/wall.jpg").toString()), "image/*");
setAs.putExtra("mimeType", "image/*");
setAs.addCategory(Intent.CATEGORY_DEFAULT);
setAs.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(setAs, "Set Image As"));
The above code does not set the image to the contacts .. I am continuing to try and if I find the solution I will put it here
We are trying to set the downloaded image (and stored inside galley under our own folder) as wallpaper using our application, and its working using the below code.
public void Set_Current_wallpaper() {
File f = new File(mCurrentWallpaperPath); // mCurrentWallpaperPath is Our folder inside gallery
Uri contentUri = Uri.fromFile(f);
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setDataAndType(contentUri, "image/*");
intent.putExtra("mimeType", "image/*");
startActivity(intent);
}
Problem is right now when above code is running below is how set wallpaper application screen looks like, But if we directly open the image from gallery and set as wallpaper, this is the wallpaper set screen looks like. Why is it opening in different way? Attaching the screens Actual vs Expected here.
Actual Result
Expected Result
Have you tried WallpaperManager?
WallpaperManager wallpapermgr = WallpaperManager.getInstance(this);
wallpapermgr.setBitmap(yourbitmap);
In my Android app, I use the following code to launch an image picker:
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/jpg");
startActivityForResult(intent, INTENT_PICK_IMAGE);
But unfortunately, the system gallery activity that is called by this also display videos. Is there a way to prevent this?
I use this to only allow image types:
intent.setType("image/*");
Edit: setType() is based on MIME type, not file extension (See here: http://developer.android.com/reference/android/content/Intent.html#setType(java.lang.String))
I have an app with thumbnails and when the user touch a thumb, I would like to open the full image in fullscreen. I try opening the image in the default Gallery app, but it doesn't work on all devices.
Here's the snippet :
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url_of_the_remote_image_here));
intent.setType("image/jpg");
startActivity(intent);
On Nexus S running 4.1, I get :
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW typ=image/jpg }
I try several snippets of code and many were opening the image in the browser. Because all Android devices have default gallery, shouldn't it be possible to open the remote image using it?
You should never assume there's activty to handle your intenet, so always wrap startActivity() in try/catch. I'd use correct mime type image/jpeg, but in fact I'd replace it with just more generic image/*.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url_of_the_remote_image_here));
intent.setType("image/*");
try {
startActivity(intent);
} catch( Exception e ) {
e.printStatckTrace();
}