Skip to content

Instantly share code, notes, and snippets.

@yccheok
Created November 9, 2021 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yccheok/bd3f4bf43116027f74f60a2b0bc81ae0 to your computer and use it in GitHub Desktop.
Save yccheok/bd3f4bf43116027f74f60a2b0bc81ae0 to your computer and use it in GitHub Desktop.
create custom share intent
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