android twitter4j oath callback to tab - android

I have a tabActivity (.Tabs) in which one of the tabs has twitter integration (.TwitterTab). From that tab, you can click a button to login to twitter. Once you authenticate with twitter on their mobile web portal, you are returned back to the app... but it goes to the twitter activity (.TwitterTab), NOT the tab activity (.Tabs).
How can i make it return to the .Tabs with the .TwitterTab tab selected?
<activity android:name=".service.oath.PrepareRequestTokenActivity" android:launchMode="singleTask">>
<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-twitter" android:host="callback" />
</intent-filter>
</activity>

When you set Scheme and Host for an activity in the Android Manifest, it tells android that all requests involving that particular Scheme and Host should be handled by that activity.
When you are authenticating using oAuth and Twitter4j, you have to provide a callback URL that is used once authentication is complete. According to your manifest excerpt above, yours would be something like: x-oauthflow-twitter://callback. When the authentication process is finished, android is told to go to the activity that handles the callback you provided. (In your case, .service.oath.PrepareRequestTokenActivity)
So, set the scheme and host for your tabActivity so that android goes back there after authenticating, and override onResume to handle the return. I'm sure there is a programmatic way to have the Twitter tab opened once you get to that point.
You can check out this post for more examples on scheme/host and twitter4j authenticating.

Related

How to create deeplinks for android using branch.io

We are trying to create some deep links for Android using branch.io but haven't had any success in last 2 days. We would be really glad if we can get some help on how to do it.
Configuration:
Android Manifest:
<activity
android:name=".login.view.DeepLinkActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.Login"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<data android:scheme="myapp" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
Branch.io Dashboard :
Under android redirects section, the value for "Android URI schema" is set to "myapp://"
The link is being generated via branch.io HTTP API. The post request is
host: v1/url
request body:
{
"alias":"xxxx",
"data":"{\"$fallback_url\":\"www.xxx.com\",\"$android_depplink_path\":\"myapp://open/\"}",
"branch_key":"key_test_xxxxxxxxxx"
}
Whenever we are trying to open this link via email, we are redirected to the fallback URL defined in branch.io dashboard.
Please help us get this configuration right.
You need to override onStart method of your launcher Activity and handle the redirection according to data passed from intent.
STEP 1: Generate Deep links using https://dev.branch.io/getting-started/creating-links/apps/android/#generate-the-link
STEP 2 : Handle the intent and take to desired activity
https://dev.branch.io/getting-started/deep-link-routing/guide/android/#building-a-custom-deep-link-routing-method
Don't forget to add android:launchMode="singleTop" in Activity Manifest to have only one instance at a time.
you can also handle this using intent.addFlag() passing Intent.FLAG_ACTIVITY_REORDER_TO_FRONT and Intent.FLAG_ACTIVITY_CLEAR_TOP. Hope this helps.

How to OAuth 2.0 login using Chrome custom tabs (Fitbit API)

Fitbit API doesn't support webview anymore.
So, I studied chrome custom tabs and applied in my app.
But after login, when I pressed this pink button(allow button), nothing happened.(Image below)
How can I receive access token and store it in app?
Please help me.
Thanks.
When authorizing agains the Fitbit API, you need to provide a redirect_uri, which is where the user will be taken after logging in. You need to provide a uri that will take the user back to your application.
To achieve that, create an intent filter and add a data tag with a custom scheme, such as myapplication://logincallback to the Activity you want to handle the login.
The intent filter will look something like this:
<intent-filter . . . >
<data android:scheme="myapplication" android:host="logincallback" />
. . .
</intent-filter>
Now, set the redirect_uri as mypplication://logincallback to the authorization step of the flow, and when the user clicks the pink button, it should open the Activity you added the intent filter.
You will be able to retrieve the parameters inside your activity by calling getData on the Intent.
<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:host="logincallback"
android:pathPattern=".*"
android:scheme="myapp" />
</intent-filter>
Suppose you have redirect_uri myapp://logincallback, then add above code in your activity in Manifest xml file and it will work.

invoking an intent using html link

I am trying to implement a new feature for my android application.
scenario :
when some event occurs, the camera sends an email to my (Gmail) account.
on opening the mail, it will have a link (html).
when user clicks on that link, it should launch my application Home activity.
I need to understand :
how to create that html link.
how can i make the link to launch my application Home activity.
kindly help me to understand what all things i need to do in my application.
I used "Blackbelt's" user comment and i was able to get the intent html link working.
But my problem is : i want to use a custom scheme "mobile" instead of "http"
I am using Gmail to use the link. But when i send using custom scheme. Gmail doesnt recogonise as hyperlink. So i cannot click on the link.
Please help me how to use a custom scheme. with gmail
you need to register an intent-filter for your Activity on the AndroidManifest.xml file, defining a custom url. . E.g.
<activity android:name="path.to.YourActivity" >
<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="https"
android:host="it.is.my.app" />
</intent-filter>
</activity>
So if you press on a link like https://it.is.my.app, you should be prompted with the android intent chooser, with your app

Twitter4j Call back issue - opening callback activity in browser

I am integrating twitter posting in my app using twitter4j library. I am following this. But I am having issue in call back. After authorizing it doesn't actually comes to our app, but actually it opens up call back activity that we specified in browser. I am not sure why this is happening.
I tried to search but couldn't find anything related to this. So May be people haven't noticed or I missed something while integrating it.
Either way please help me to resolve this issue.
It's opening the custom URL link inside the browser itself because you haven't defined which activity should handle the custom links Or You haven't defined proper categories. Here is a sample. Make sure you include the categories. The android.intent.category.BROWSABLE will ensure that the browser opens your app.
private final String CALLBACKURL = "x-oauthflow-twitter://privlyT4JCallback";
<activity
android:name=".TwitterLinkGrabberService"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleInstance" >
<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:host="privlyT4JCallback"
android:scheme="x-oauthflow-twitter" />
</intent-filter>
</activity>
you already install app with same callback, you must change the callback String from manifest and
call back constant from activity.try to use unique call back Address.
<data android:scheme="login-twitter" android:host="callback1" />
and
static final String TWITTER_CALLBACK_URL = "login-twitter://callback1";

android twitter outh tutorial callback problem

Trying the following tutorial
http://www.androidsdkforum.com/android-sdk-development/3-oauth-twitter.html
i am having trouble understanding callback URL
my twitter app name is "faisal-android" and my call back url i defined in code is
myapp://wozzon-android
and having entry in xml file as
<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="myapp" android:host="faisal-android" />
</intent-filter>
m i way to defining callback url is correct ??
when i run the code it gives me error "Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match"
my twitter app account settings as following
alt text http://www.freeimagehosting.net/uploads/a0c2689c73.png
I think you need to check browser and not client if you use a callback url
I read something about this :
http://blog.sogeti.com/mobile/2010/03/twitter-oauth-for-android.html
(dead link)
Android – OAuth updates to Twitter
http://dev.bostone.us/2009/07/16/android-oauth-twitter-updates/#awp::2009/07/16/android-oauth-twitter-updates/
Check your callback UL in twitter . Enter any dummy URL not kept empty .
You can write google.com, it work in my case.

Categories

Resources