Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Facebook和Youtube未在Android活动选择器上显示_Android_Facebook_Android Intent_Android Activity - Fatal编程技术网

Facebook和Youtube未在Android活动选择器上显示

Facebook和Youtube未在Android活动选择器上显示,android,facebook,android-intent,android-activity,Android,Facebook,Android Intent,Android Activity,我的Android应用程序包含链接,我想在Facebook上共享此链接。我用了Intent.ACTION\u SEND但是为什么 Facebook图标未显示在活动选择器上,我的代码: Intent sharing = new Intent(Intent.ACTION_SEND); sharing.setType("text/html"); sharing.putExtra(Intent.EXTRA_SUBJECT, "Check out thi

我的Android应用程序包含链接,我想在Facebook上共享此链接。我用了
Intent.ACTION\u SEND
但是为什么

Facebook图标未显示在活动选择器上,我的代码:

        Intent sharing = new Intent(Intent.ACTION_SEND);

        sharing.setType("text/html");

        sharing.putExtra(Intent.EXTRA_SUBJECT, "Check out this video");

        sharing.putExtra(Intent.EXTRA_TEXT,
                "https://www.youtube.com/watch?v=" + videoUrl);

        startActivity(Intent.createChooser(sharing, "What to share?"));
改变

这个修改解决了这个问题。希望它能帮助你


另外,请检查我用于使用特定应用程序共享链接的代码:。

我认为您需要为共享目的设置程序包

例如,如果要设置Facebook软件包,则需要执行以下操作:

List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(share, 0);
for (ResolveInfo info : resInfo) {
      String packageName = info.activityInfo.packageName;
        if(packageName.toLowerCase().contains("facebook")) {
            share.setPackage(info.activityInfo.packageName);
        }
}
List resInfo=getPackageManager().queryInputActivities(共享,0);
对于(ResolveInfo:resInfo){
字符串packageName=info.activityInfo.packageName;
如果(packageName.toLowerCase().包含(“facebook”)){
share.setPackage(info.activityInfo.packageName);
}
}

我也不工作,我检查了这个,但是没有包包含“facebook”,即使facebook应用程序已经安装。可能您需要将包名转换为小写。请检查我编辑的代码。这是我使用特定应用程序(包括facebook)共享文本的代码。它在这里工作得很好。其他应用程序是否显示在选择器中?也许你的问题与Facebook应用程序本身有关@Binngokute我更新了我的答案,你能接受你的问题的正确答案吗?:)
sharing.setType("text/plain");
List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(share, 0);
for (ResolveInfo info : resInfo) {
      String packageName = info.activityInfo.packageName;
        if(packageName.toLowerCase().contains("facebook")) {
            share.setPackage(info.activityInfo.packageName);
        }
}