Integrating Facebook and LinkedIn in Android app - android

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

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.

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

Related

Android deep link using intent not opening app

I am trying to open an app that I made from mobile chrome browser.
https://developer.chrome.com/multidevice/android/intents
From this link, I figured that I must use the "intent:" syntax to do the job.
However, my app doesn't open. Instead, it opens the Google Play Store, but the store just shows the "item not found" page.
I would love to know if I'm doing anything wrong.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="myscheme" android:host="myhost" android:path="/"/>
</intent-filter>
This is the intent filter that I wrote.
var androidIntentUrl = 'intent://myhost/#Intent;scheme=myscheme;package=my.test.app.package;end';
if(!isIOS && isChromeAndBiggerThanVer25()) {
location.href = androidIntentUrl;
}
And this is what I wrote on the web.
Must the app be released on Play Store to make this happen?
I don't quite understand the whole stuff yet.
I want to know what's wrong.
PS) The names "myscheme" and "myhost" are just names that I made up for writing this question. The actual names in my code match those written in my project settings and all, including the package name.
As Alexey commented on my post,
<a href="myscheme://myhost/some/other/parameters">
worked just okay for me.
I double checked the official document (the link on my post) and my chrome version (which is 71), so I have no idea why the intent:// syntax did not work.
I guess there were changes on mobile Chrome after version 25 that I missed or couldn't find.
I just encountered the same problem where linking with Intents did not work but the direct scheme linking did. However, I didn't want to use the direct version to have a fallback redirect to the PlayStore.
The solution was that the package parameter in the intent link did not have to match the package given in the AndroidManifest.xml. I was working with a Unity project and had to use the bundle name given in the project setting.
tl;dr: this is still working in Chrome (v78), but the package parameter is not necessarily the package given in the manifest.
The package parameter should match your application id (found in build.gradle or your AndroidManifest.xml)
The sample code above shows package as my.test.app.package, if this is not your app package name or if the app is not installed, the intent will default to the Google Play Store to search for it. Similarly, it would be best change the host and scheme parameters to something custom to your app if you haven't already.
My answer is to open android application from web app using deep linking:
Flipkart - Open Flipkart!
WhatsApp - Open WhatsApp!
Clash Royale - Open Clash Royale!
FaceBook - Open FaceBook!
If the listed application is installed in your mobile then only it will open or you have to handle the case separately.

Alibaba android app causes crash when you try to open an URL [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
When you try to open a link, from example from whatsapp, the app (in this case whatsapp) crashes. This only happens if you have alibaba app installed in your device.
Reproduction path:
install alibaba app (https://play.google.com/store/apps/details?id=com.alibaba.intl.android.apps.poseidon&hl=en)
try to open url
app crashes (or it can't find any
other activities to open the link, even not the chrome browser.)
The crash what we see in our app is:
Fatal Exception: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.VIEW dat=http://www.nu.nl cmp=com.alibaba.intl.android.apps.poseidon/com.alibaba.android.intl.weex.activity.WeexPageActivity VirtualScreenParam=Params{mDisplayId=-1, null, mFlags=0x00000000)} } from ProcessRecord{7307f55 18243:.../u0a226} (pid=18243, uid=10226) not exported from uid 10207
From what I infer, this is a bug corresponding to the alibaba app. Firstly it is associated with deep linking feature which allows Apps to open URI indigenous to them. For example : quora app or reddit app. This would open inside the Quora instead of Chrome to enhance the experience.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="reddit.com"
android:pathPrefix="/r"
android:scheme="https" />
</intent-filter>
Something like this. I suspect that the alibaba app would have routed all the hosts towards their app. They would have liberally used the wildcards which would have made their app to be opened from literally any url. Also the crash is due to denial of permission. This happens when you try to open a non-exported activity from context outside of the app.
PS: In short words, this is solely an issue with alibaba B2B app. This can only be fixed from their side. Try clearing defaults and routing all urls back to chrome as android asks your choice to select the default application for any uri.

How can I automatically get OAuth 2.0 token and re-open my app?

I'm working with the Delivery.com API in building my app, and my current understanding of how the OAuth flow works is:
I redirect the user to the browser, where they explicitly sign in to their account. I supply a redirect_uri in the process.
Upon sign in, the user is redirected to the redirect_uri with an access token
I get the access token somehow, and use this to authenticate future actions in my app
It's step 3 that I'm struggling with - I've set up an Intent and intent-filter such that I correctly open the browser for step 1, and the user is correctly redirected back to my app in step 2. But this leaves two problems:
The redirect_uri which re-opens my app does so in the background - the browser never closes. I'm assuming there's a simple fix for this, but haven't been able to find it.
How do I get the access token? Is the only solution to redirect to another webpage which will display the token, and then have the user manually copy and paste this back into my app? Or can I somehow automatically get the token, re-open my app, and proceed?
EDIT: I was able to get this working - I'm not sure what was causing the issue in point #1 above, but after changing things back and forth a few times it started working as I originally had it. For anyone who looks into this in future, I had to include all the following elements in my Manifest.xml for it to work:
<action android:name=android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="myapp.randomname" android:host="my_url"/>
Regarding problem #2, I was able to parse the response by using Uri data = getIntent().getData() and then calling data.getQueryParameter("fieldname").
Instead of launching external browser and using intent filters you should benefit more from using WebView directly in your app and getting thru OAuth with it.

Cannot receive search queries from Google Now

I am trying to connect Google Now SEARCH_ACTION with my searchable activity using this piece of code in my AndroidManifest.xml:
<activity android:name=".SearchableActivity">
<intent-filter>
<action android:name="com.google.android.gms.actions.SEARCH_ACTION"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
I am following instructions on http://android-developers.blogspot.com/2014/10/the-fastest-route-between-voice-search.html and https://developer.android.com/guide/components/intents-common.html#SearchOnApp.
This is just not working. The search from Google Now is not launching my app. I have verified that:
This works for Eat 24 app, confirming that there's no issue with right version of OS/Google app/Locale.
I can launch app from inside my app and receive typed search queries, confirming that my SearchableActivity code doesn't have any issues.
Anyone has gotten this to work? Could you please let me know what I am missing here?
Well... looks like the app needs to be published on Play Store:
https://plus.google.com/+AndroidDevelopers/posts/afSRdDQiy1N - look for comments by Jarek Wilkiewicz. Going to try this next.

Deep link shares to Google+, but link does nothing

I'm trying to use deep-linking from Google+ into an Android app, following http://developers.google.com/+/mobile/android/share/deep-link.
I can share to Google+. The link in the post is "clickable" (it highlights during touch), but does nothing on release. Also, the post contains a suspicious "undefined" line of text.
sample http://raw.github.com/concreterose/TestDeepLink/master/README_ASSETS/sample_share.png
I have enabled deep linking in Google Developers Console project credentials.
I'm using a signed-in PlusClient created with Scopes.PLUS_LOGIN, posting via:
Intent shareIntent = new PlusShare.Builder(this, plusClient)
.setText("Testing deep link")
.setType("text/plain")
.setContentDeepLinkId("deeplink",
"title",
"description",
Uri.parse(thumbnailUrl))
.getIntent();
startActivityForResult(shareIntent, 0);
I'm not sure if I need all of these, while trying to get things working I have:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
The handling activity (given as the first activity in the manifest):
<activity android:name=".ParseDeepLinkActivity">
<intent-filter>
<action android:name="com.google.android.apps.plus.VIEW_DEEP_LINK" />
<data android:scheme="vnd.google.deeplink" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
is:
public class ParseDeepLinkActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "onCreate");
throw new RuntimeException("got here");
}
}
I'm building with the release keystore and testing on a several real devices running 4.4.
I've tried:
Using the PlusShare.Builder(activity) constructor (without plusClient), no change.
Using addCallToAction(label, uri, deeplink) instead of setContentDeepLinkId. There is no call to action button, and clicking the post goes to uri and not the deep link.
Triple checking "Deep linking: Enabled" is set correctly in the developers console.
Building without proguard, no change.
Uninstalling the app then clicking the link (supposed to open the play store entry), does nothing.
Signing with a different key. Plus sign in fails (as expected).
Using different versions of play services (4.0.30 vs 3.2.+).
adb shell setprop log.tag.GooglePlusPlatform VERBOSE does not generate any log messages.
Fetching my API access token and verifying it has auth/plus.login, it does.
Can anyone tell me what I'm doing wrong? Thanks!!
Update: This is now working, apparently fixed by a Google Play Services update.
It turns out this a known issue that will be fixed with the next Google+ update:
Google+ Interactive shares on android are broken in version 4.2.4.58179886
Its generally best to share a URL marked up with schema.org rather than passing the title, description and image. Because there is no URL, the link will never be clickable on web (you need to use setContentURL to have that) - but it should open the application on Android.
That said, the undefined does indeed look suspicious. There are two concerning things there, the first being that the link doesn't work, and the second that description is no longer generally shown in regular shares. There is a known issue with interactive posts to Android, which hopefully should be resolved early in the new year, and I am wondering if that is also effecting the sharing of deeplinks.
To narrow it down, could you try testing with schema.org marked up URL in setContentURL (e.g. https://developers.google.com/+/web/snippet/examples/thing), and passing null for title, image and description on the setContentDeeplink call?

Categories

Resources