Integrating Facebook and LinkedIn in Android app

别等时光非礼了梦想. 提交于 2019-12-23 17:01:28

问题


I have an app that integrates both Facebook and LinkdedIn networks. According to the instructions, in order to integrate LinkedIn, I need to add the following code in my manifest, within my activity:

<intent-filter>
   <action android:name="android.intent.action.VIEW" />
   <category android:name="android.intent.category.DEFAULT" />
   <category android:name="android.intent.category.BROWSABLE" />
   <data android:scheme="x-oauthflow-linkedin" android:host="callback" />
</intent-filter>

An example can also be found here. As you can see in the link, we need to add also the " android:launchMode="singleInstance" " line, otherwise after logging in with LinkedIn a new instance of the activity will be started.

However, when trying to log in to Facebook from the same activity, this actual line results to the following error from the Facebook Login activity (!):

E/AndroidRuntime(7100): Caused by: com.facebook.FacebookException: Cannot call LoginActivity with a null calling package. This can occur if the launchMode of the caller is singleInstance.

So now, I'm somehow stuck, because removing android:launchMode="singleInstance" will make Facebook login working, but will cause the LinkedIn login to start another instance of my activity, but if I add it, then Facebook login is not working!

Does anyone have any idea how to address this issue?

Thank you,

Dimitris


回答1:


After reading little bit on the documentation, it seems that replacing the singleInstance with singleTask did the trick. Although, I haven't figured out exactly why, I am posting this for others to see it in case someone needs it. I'll try to dig further and understand why, but in the mean time if anyone can explain why this is working, it would be nice.




回答2:


This sdk can integrate you to handle both facebook and linkedin without any hassle. Also use valid url for linkedin callback.



来源:https://stackoverflow.com/questions/15348346/integrating-facebook-and-linkedin-in-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!