-
-
Save illuzor/7889e1f3c0c602dc8087135690a3ddc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun shareWallpaper() { | |
val sharingIntent = ShareCompat.IntentBuilder | |
.from(activity) | |
.setType("image/*") | |
.intent | |
if (activity!!.packageManager.resolveActivity(sharingIntent, PackageManager.MATCH_DEFAULT_ONLY) == null) { | |
toast(R.string.no_apps_for_share) | |
} else { | |
sharingIntent.putExtra(Intent.EXTRA_STREAM, imageFileUri) | |
val activities = activity!!.packageManager.queryIntentActivities(sharingIntent, PackageManager.MATCH_DEFAULT_ONLY) | |
for (activity in activities) { | |
getActivity()!!.grantUriPermission(activity.activityInfo.packageName, imageFileUri, Intent.FLAG_GRANT_READ_URI_PERMISSION) | |
} | |
startActivityForResult(Intent.createChooser(sharingIntent, getString(R.string.share_image)), SHARING_REQUEST_CODE) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment