Created
November 9, 2021 13:55
-
-
Save yccheok/bd3f4bf43116027f74f60a2b0bc81ae0 to your computer and use it in GitHub Desktop.
create custom share intent
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
if (shareIntent.resolveActivity(context.getPackageManager()) != null) { | |
List<Intent> targetedShareIntents = new ArrayList<>(); | |
Intent x = new Intent(Intent.ACTION_SEND); | |
x.setClassName("com.yocto.wenote", | |
"com.yocto.wenote.widget.SortLauncherFragmentActivity"); | |
x.setType("vnd.android.cursor.item/vnd.socialnmobile.colornote.note.title"); | |
targetedShareIntents.add(x); | |
final Intent chooserIntent = Intent.createChooser(shareIntent, context.getString(R.string.share_note)); | |
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[targetedShareIntents.size()])); | |
try { | |
fragment.startActivityForResult(chooserIntent, REQUEST_SHARE); | |
} catch (Exception e) { | |
// Caused by android.os.TransactionTooLargeException: data parcel size 1573792 bytes | |
Log.e(TAG, "", e); | |
trackEvent("share", "fatal", e.getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment