- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我举了一个关于在 android 中使用 facebook sdk 将我的状态(包括链接、照片、视频)发布到我的墙上的例子。按照这个 facebook 的教程链接:facebook startup tutorial我已经通过 ShareLinkContent 类成功登录并发布了链接状态。但是如果没有安装官方 android facebook 应用程序,我无法共享照片(SharePhotoContent 类)和视频(ShareVideoContent 类)。本教程不要求必须先安装他们的应用程序,但我无法使用我的示例应用程序在没有安装他们的应用程序的情况下发布我的照片、视频。
ShareDialog.canShow(ShareLinkContent.class)
无论安装了他们的 Facebook 应用程序,总是返回 true
ShareDialog.canShow(SharePhotoContent.class)
ShareDialog.canShow(ShareVideoContent.class)
只有安装了他们的 facebook 应用程序才返回 true
我分享照片的代码:
public void sharePhoto() {
Bitmap image = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
SharePhoto photo = new SharePhoto.Builder().setBitmap(image).build();
SharePhotoContent content = new SharePhotoContent.Builder().addPhoto(photo).build();
ShareDialog dialog = new ShareDialog(this);
if (ShareDialog.canShow(SharePhotoContent.class)){
dialog.show(content);
}
else{
Log.d("Activity", "you cannot share photos :(");
}
}
分享视频的代码:
public void shareVideo() {
Uri selectedVideo = Uri.parse(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + "Video" + "/fight.mp4");
if (ShareDialog.canShow(ShareVideoContent.class)) {
ShareVideo shareVideo = new ShareVideo.Builder().setLocalUrl(selectedVideo).build();
ShareVideoContent shareVideoContent = new ShareVideoContent.Builder()
.setVideo(shareVideo)
.setContentTitle("Video Title")
.setContentDescription("Video description")
.build();
ShareDialog dialog = new ShareDialog(this);
dialog.show(shareVideoContent);
} else{
Log.d("Activity", "you cannot share videos :(");
}
}
我已经设置了我的应用程序的权限:“publish_actions”。
我错过了什么吗?还是真的我必须先安装 facebook 应用程序,然后才能使用他们提供的 sdk(以防发布照片、视频)开发我的应用程序?
最佳答案
你初始化Facebook SDK了吗.......如果是,那么请求这样的许可
Set<String> permissions = AccessToken.getCurrentAccessToken()
.getPermissions();
final List<String> PUBLISH_PERMISSIONS = Arrays
.asList("publish_actions");
if (!permissions.containsAll(PUBLISH_PERMISSIONS)) {
// pendingPublishReauthorization = true;
LoginManager.getInstance().logInWithPublishPermissions(this,
PUBLISH_PERMISSIONS);
return;
}
然后检查你是否能够像这样发布网络图像......
ShareLinkContent content1 = new ShareLinkContent.Builder()
.setContentUrl(
Uri.parse("https://play.google.com/store/apps/details?id=pk.wisesolutions.naatcollection"))
.setContentTitle(final_messgae)
.setContentDescription(
"Naat Collection App - listen to hundreds of naats free")
.setImageUrl(
Uri.parse("http://apps.wisesolutions.pk/app/naatcollection/images/logo_180x180.png"))
.build();
MessageDialog.show(mContext, content1);
关于android - 分享媒体内容使用 facebook sdk 4.x+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31375657/
似乎最近我看到越来越多的人开始在他们的样式表中使用 media="all" 而不是 media="screen"。 我的问题是什么时候应该使用 media="all" 而不是 media="scree
我正在尝试使用 https://www.instagram.com/developer/endpoints/media/ ,但对于我使用的每个媒体 ID,我总是得到相同的结果: { "meta
哟,我正在为服务器制作一个 MOTD 供最终用户阅读。但是,对于使用较小显示器的用户来说,它看起来非常压缩,例如,当分辨率为 1280x1040 时,它会被拉低。我不熟悉 CSS 中的 @media
我在我的 CSS 文件中使用了 @media screen 而不是 (-webkit-min-device-pixel-ratio:0)。我的问题是关于指定的值,即在这种情况下为“0”。值的变化将如何
我正在播放 Activity 中的视频,我需要显示/隐藏顶部栏 View 以及媒体 Controller 。所以当媒体 Controller 在屏幕上时,我的顶部 View 应该是可见的,当媒体 Co
我在我的 WordPress 主题中创建了一个小部件来显示图像。到目前为止,小部件可以工作,我可以输入值并在前端显示这些值。 当我选择一个小部件并将其放入小部件区域时,媒体上传按钮不起作用。在 Wor
我正在使用MWFeedParser从此处读取Youtube原子供稿:here xml代码: 我如何获取媒体的网址:缩略图? 我试图更改MWFeedParser.m 由此: else if ([cu
当使用 Python 向 Instagram API 发出 GET 请求时,传递所需的变量,如下所示 photos = api.media_search(lat=latitude, lng=longi
我正在使用与媒体播放器关联的媒体 Controller 来播放声音。问题是媒体 Controller 一旦失去焦点就会隐藏起来。我有一个按钮,按下时会播放声音,媒体 Controller 会出现在屏幕
我有一个媒体播放器并与它关联了一个媒体 Controller 。控件工作正常。 我遇到了两个问题: 当媒体 Controller 获得焦点时,即用户触摸它然后触摸屏幕的另一部分时,媒体 Control
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我在对话框中显示一个 VideoView 并向其附加一个媒体控件。 但是当我尝试点击媒体控件(播放、搜索栏等)时,对话框会消失。 媒体控制按钮不会被点击,而是将点击注册为 Dialog 的 Outsi
我目前正在使用 HTML 编写可打印文档,它将显示从数据库中提取的数据。我的想法是我将使用 HTML/CSS 使文档看起来不错,但它将专门用于打印。 文档的布局使用表格来控制数据库中数据的显示方式。
我需要在网络应用程序中打印我的报告。 我有在我的代码中。但它不应用任何样式。另一方面,如果我使用 在文档中编写 print.css 代码一切正常。 怎么了? 最佳答案 也许你在主样式之前插入打印样式
CSS html{ overflow-y:scroll; } js function showW(){ var a=($(window).width()); $('#
我编写了一个 Chrome 扩展程序,其中一个功能是您可以在您所在的页面中调出一个帮助面板,其中包含其使用指南。这个帮助面板是通过JS插入到页面中的,它的CSS都是通过$('#selector_for
我需要为 WORM 媒体开发归档软件。 这种类型的媒体允许通常的访问操作:读取、写入,但文件一旦写入,就无法修改或删除。 因为这样的媒体可能很昂贵,我想知道如何在开发阶段为测试创建一个假的 WORM
下面的这个 Activity 工作正常,但 mediaController 仅在我单击屏幕时显示。第二个问题是媒体 Controller 只显示 3 秒。我应该怎么做才能消除这个问题? public
我正在使用 VideoView 播放本地 mp4,我也在使用 MediaController。媒体控制栏未显示在我的视频剪辑下方,而是显示在屏幕中间。我使用 setAnchorView 将其附加到我的
我的布局包含 videoView 还有java代码中的Medicontrolleri: final MediaController mediaCont
我是一名优秀的程序员,十分优秀!