Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share video from youtube is giving items [null] #27

Open
pateldi1524 opened this issue Aug 27, 2018 · 5 comments
Open

Share video from youtube is giving items [null] #27

pateldi1524 opened this issue Aug 27, 2018 · 5 comments

Comments

@pateldi1524
Copy link

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.

@Tony556
Copy link

Tony556 commented Aug 19, 2019

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

@mehdiym
Copy link

mehdiym commented Aug 26, 2019

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='*/*'

@manix
Copy link

manix commented Mar 12, 2022

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

@alextapia007
Copy link

still the issue

@alextapia007
Copy link

alextapia007 commented Aug 18, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants