0

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,

1 Answers1

0

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.

C4s4r
  • 404
  • 3
  • 7