Android和Facebook分享意图(Android and Facebook share intent)
我正在开发一个Android应用程序,并且有兴趣知道如何使用Android的共享内容从应用程序中更新应用程序用户的状态。
通过Facebook的SDK看来,这看起来很简单,但是我很想让用户通过普通的Share Intent弹出窗口来完成它? 看到这里:
我已经尝试了通常的分享意图代码,但这不再适用于Facebook。
public void invokeShare(Activity activity, String quote, String credit) { Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, activity.getString(R.string.share_subject)); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Example text"); activity.startActivity(Intent.createChooser(shareIntent, activity.getString(R.string.share_title))); }
更新:做了更多的挖掘,看起来好像是一个bug的Facebook的应用程序尚未解决! ( facebook bug )与此同时,看起来我只是要忍受负面的“分享不起作用!!!” 评论。 欢呼Facebook:*(
I'm developing an Android app and am interested to know how you can update the app user's status from within the app using Android's share intents.
Having looked through Facebook's SDK it appears that this is easy enough to do, however I'm keen to allow the user to do it via the regular Share Intent pop up window? seen here:
I have tried the usual share intent code, however this no longer appears to work for Facebook.
public void invokeShare(Activity activity, String quote, String credit) { Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, activity.getString(R.string.share_subject)); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Example text"); activity.startActivity(Intent.createChooser(shareIntent, activity.getString(R.string.share_title))); }
UPDATE: Having done more digging, it looks as though it's a bug with Facebook's app that has yet to be resolved! (facebook bug) For the mean time it looks like I'm just going to have to put up with the negative "Sharing doesn't work!!!" reviews. Cheers Facebook :*(
原文:https://stackoverflow.com/questions/7545254
最满意答案
尝试这个
在以下代码中添加
didRotateFromInterfaceOrientation
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
编辑
不需要在所有视图控制器中编写代码
将View controller-based status bar appearance
设置为“NO
,并在根视图控制器的viewDidLoad
添加以下代码[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
演示项目
https://www.dropbox.com/s/uumneidk4wom5md/demoStatusBar.zip?dl=0Try this
Add below code in
didRotateFromInterfaceOrientation
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
EDIT
NO NEED TO WRITE CODE IN ALL VIEW CONTROLLER
SetView controller-based status bar appearance
toNO
inplist
and add below code in root view controller'sviewDidLoad
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
Demo project
https://www.dropbox.com/s/uumneidk4wom5md/demoStatusBar.zip?dl=0
相关问答
更多-
在ios 9中隐藏状态栏(Hide the status bar in ios 9)[2024-02-08]
斯威夫特-3 override var prefersStatusBarHidden: Bool { return true } 我从这里得到了信息 将func更改为var 删除() 更改->到: 这是可行的,因为一个计算变量具有一个getter函数,所以你之前实现的函数只是变成了getter函数 2016年起:简单的事情 在你的info.plist中为statusBar Hidden添加以下两个属性 基于视图控制器的状态栏外观(布尔值:NO) 状态栏最初是隐藏的(布尔:是) 按来源 ... -
尝试这个: [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade]; 从Apple类参考: setStatusBarHidden:withAnimation: 隐藏或显示状态栏,可选择对转换进行动画处理。 - (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animati ...
-
尝试这个 在以下代码中添加didRotateFromInterfaceOrientation [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone]; 编辑 不需要在所有视图控制器中编写代码 将View controller-based status bar appearance设置为“ NO ,并在根视图控制器的viewDidLoad添加以下代码 [[UIApplic ...
-
对不起,如果这个答案有点晚,但这是一种方法。 在视图控制器中使用prefersStatusBarHidden()方法。 override func prefersStatusBarHidden() -> Bool { if self.navigationController?.navigationBarHidden == true { return true } else { return false } } 基本上说,当导航栏被隐藏时,状态栏也是如 ...
-
在Info.plist中,将“查看基于控制器的状态栏外观”设置为NO 在AppDelegate中添加 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; } 此解决方 ...
-
动画状态栏iOS 7(Animating status bar iOS 7)[2023-02-10]
此代码以纵向方式工作,但需要进行修改才能在两个方向上正常工作。 它使用单独的UIWindow作为叠加层,因此无需隐藏或取消隐藏状态栏。 @interface ViewController () @property (strong,nonatomic) UIWindow *dropdown; @property (strong,nonatomic) UILabel *label; @property (strong,nonatomic) UIWindow *win; @end @implementation ... -
您可以使用requestAlwaysAuthorization而不是CLLocationManager上的requestWhenInUseAuthorization(并在info.plist文件中提供相关的NSLocationAlwaysUsageDescription),然后它也不会出现。 看到这个答案 You can use requestAlwaysAuthorization instead of requestWhenInUseAuthorization on CLLocationManager ( ...
-
改变这种方法 - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeRight; } 以及此属性:在您的项目中 - >常规 - >设备方向,选中纵向和横向右侧。 Resolved by adding the following methods, - (void)viewWillAppear:(BOOL)animated { [[UIApplication sharedAppl ...
-
启动iOS8上使用UIPageViewController的黑色状态栏(Black status bar on startup iOS8 using UIPageViewController)[2022-02-08]
在放弃之前,我试图解决这个问题大约10个小时。 当我试图解决另一个问题时,我终于解决了它,并找到了一个值得一试的方法。 在为UIPageViewController设置委托后,只需将其放入 pageViewController.automaticallyAdjustsScrollViewInsets = NO; I tried to solve this for ~10 hours before giving up. I finally solved it when I was trying to sol ... -
setStatusBarHidden设置和“状态栏最初隐藏”Info.plist设置不起作用,除非您还将“基于视图控制器的状态栏外观”Info.plist键( UIViewControllerBasedStatusBarAppearance )设置为“NO”。 换句话说,要么是在每个顶级视图控制器的级别上执行此操作,要么是在全局UIApplication级别执行此操作,并且此键确定它是什么。 但是,最好学习以视图控制器的方式进行操作,因为Apple最终可能会取消在全局UIApplication级别执行此操作 ...