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.
Related
I am doing an Android file explorer. How can I execute a file?
For example : "/xxx/xxx/image.jpg"
I need to display the image in the default android system image viewer when the user clicks on the name of the file.
You can use an intent to do that.
Intent intent = new Intent();
//Action View to see an image in default native app in your device.
intent.setAction(Intent.ACTION_VIEW);
//The path to see your image.
intent.setDataAndType(Uri.parse("file://" + "/sdcard/test.jpg"), "image/*");
startActivity(intent);
Without knowing much about the code itself you can try with:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + "your_image_path.jpg"), "image/*");
startActivity(intent);
ACTION_VIEW as per Android Documentation:
Display the data to the user. This is the most common action performed
on data -- it is the generic action you can use on a piece of data to
get the most reasonable thing to occur.
I have an image/pdf/docx/video as part of a listview item. I want to open them with appropriate applications in android. Currently only the video seem to open properly. Rest does not work. Can someone kindly help me !!!
Here is my code snippet I use from onItemClick in a ListView:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(itemPath), "*/*");
//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
I tried :
intent.setDataAndType(Uri.parse(itemPath), "image/*");
for image files and
intent.setDataAndType(Uri.parse(itemPath), "application/pdf");
for pdf files too. But none work.
Thanks.
I have a bitmap downloaded from a url and want to start android's default set as wallpaper intent/activity passing my bitmap. I have found following solution but missing value of "R.String.set_as" and "REQUEST_ID_SET_AS_WALLPAPER".
https://stackoverflow.com/a/26869604/4767525
what should be the value of this fields?
Thanks
Don't really know about REQUEST_ID_SET_AS_WALLPAPER. I think it is related to the size of the image.
R.String.set_as is just a string: "Set as:"
Use this code:
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.setDataAndType(contentUri, "image/*");
intent.putExtra("mimeType", "image/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(
intent, "Set as:"));
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 would like to open just one image and have pitch-zoom function, so (as I think) easiest way to do that is to open that image in gallery intent. Anybody can share example of how to call gallery intent with particular picture from drawable?
I tried to used something like that but can't make it working (wrong file patch?).
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("com.me.example/drawable/thisimage.png"), "image/*");
startActivity(intent);
According to this post
You should do something like:
String uriStr = "android.resource://"+ "com.example.myapp"+ "/" + R.drawable.photo_h01;
Uri uri = Uri.parse(uriStr);
I have not Eclipse in front of me but that's what I have found on several sources