cordova-plugin-openwith icon indicating copy to clipboard operation
cordova-plugin-openwith copied to clipboard

Share video from youtube is giving items [null]

Open pateldi1524 opened this issue 6 years ago • 5 comments

I have added this plugin to my project. When I share video link from android youtube application, it opens my app but items are null.

pateldi1524 avatar Aug 27 '18 05:08 pateldi1524

Same issue in late 2019. @j3k0, any ideas?

Tony556 avatar Aug 19 '19 11:08 Tony556

Same here, items array contains a single null value. It happens if I try to share a link or some text. It seems to work with an image.

I install the plugin with ANDROID_MIME_TYPE='*/*'

mehdiym avatar Aug 26 '19 14:08 mehdiym

+1, sharing a video from youtube I can't get the url

manix avatar Mar 12 '22 17:03 manix

still the issue

alextapia007 avatar Aug 17 '22 21:08 alextapia007

hi, this work for me. check if in AndroidManifest.xml has the following:

<intent-filter>
    <data android:mimeType="image/jpeg" />
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
    <data android:mimeType="text/plain" />
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

In Serializer.java replace public static JSONObject toJSONObject:

 public static JSONObject toJSONObject(

        final ContentResolver contentResolver,
        final Intent intent)
        throws JSONException {
    JSONArray items = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        items = itemsFromClipData(contentResolver, intent.getClipData());
    }
    if (items == null || items.length() == 0) {
        items = itemsFromExtras(contentResolver, intent.getExtras());
    }
    if (items == null || items.length() == 0) {
        items = itemsFromData(contentResolver, intent.getData());
    }
    if (items != null) {
        if (items.get(0).toString() == "null" && dedondetxt=="getClipData") {
            final JSONObject json = new JSONObject();
            final LocalDateTime fechahora = LocalDateTime.now();
            json.put("fechahora", fechahora);
            json.put("urltxt", (String) intent.getExtras().getString(Intent.EXTRA_TEXT));
            json.put("type", (String) "text/url");
            json.put("dedondetxt", (String) dedondetxt);

            final JSONObject[] itemstxt = new JSONObject[1];
            itemstxt[0] = json;
            items = new JSONArray(itemstxt);
        }
    }
    if (items == null) {
        return null;
    }
    final JSONObject action = new JSONObject();
    action.put("action", translateAction(intent.getAction()));
    action.put("exit", readExitOnSent(intent.getExtras()));
    action.put("items", items);
    return action;
}

i hope this help you.

alextapia007 avatar Aug 18 '22 20:08 alextapia007