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";
Related
I want to open my app and load the URL when specific links are clicked.
This is my Manifest for handling external links.
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="www.android.com" />
<data android:scheme="https" android:host="www.android.com" />
</intent-filter>
And for handling incoming links this is the code
intentData = getIntent().getData();
if(intentData !=null){
loadUrl = intentData.toString();
}else {
loadUrl = "https://www.android.com";
}
webView.loadUrl(loadUrl);
Now when I clicked https://www.android.com from external app like whatsapp its loaded in webview but the webview is attached to whatsapp. Check screenshots below.
And if anyone can give me any hints or guide me on how to open my app when I open the URL(https://www.android.com) from Google Chrome(in my phone) will be a great help
For second part of your question:
And if anyone can give me any hints or guide me on how to open my app
when I open the URL(https://www.android.com) from Google Chrome(in my
phone) will be a great help
take a look at this answer:
"Essentially, the Chrome team feels that if a user actually types something into the address bar, no redirect should ever happen. As you've discovered, this is counter to behavior in all other browsers."
Use this line in Manifest file of your Activity which is Handling that intent to avoid such problem.
android:launchMode="singleTask"
You can find detail implementation here, https://developer.android.com/guide/webapps/webview.html
You have to override methods, and handle clicks.
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.
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.
I don't know if many people have tried this but I am trying a build an app that requires user to tap on a link on the sms he/she receives and this will launch the android app. Is it possible to do in android? If yes, how can I do this? I know this can be done in IOS. Any suggestions or help will be appreciated. Thank You.
In you Manifest, under an Activity that you want to handle incoming data from a link clicked in the messaging app, define something like this:
<activity android:name=".SomeActivityName" >
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<data android:scheme="com.your_package.something" />
</intent-filter>
</activity>
The android:scheme="" here is what will ensure that the Activity will react to any data with this in it:
<data android:scheme="com.your_package.something" />
In the SomeActivityName (Name used as an illustration. Naturally, you will use your own :-)), you can run a check like this:
Uri data = getIntent().getData();
String strData = data.toString();
if (strScreenName.equals("com.your_package.something://")) {
// THIS IS OPTIONAL IN CASE YOU NEED TO VERIFY. THE ACTUAL USAGE IN MY APP IS BELOW THIS BLOCK
}
My app's similar usage:
Uri data = getIntent().getData();
strScreenName = data.toString()
.replaceAll("com.some_thing.profile://", "")
.replaceAll("#", "");
I use this to handle clicks on twitter #username links within my app. I need to strip out the com.some_thing.profile:// and the # to get the username for further processing. The Manifest code, is the exact same (with just the name and scheme changed).
Add an intent-filter to your app that listens for links that follow the format you want your app to be launched on.
However, this will be a global listener, and any link that fits the format even outside the SMS app will trigger your app. So if the user taps a similar link in the web browser, your app will attempt to respond to it.
Additionally, if there is another app besides yours that can handle this link, Android will create a chooser that allows the user to pick whichever app they want to use. There is nothing you can do about this, except suggest that the user make your app the default handler for such links.
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"
<data android:scheme="https" android:host="${hostName}" android:pathPattern="/.*" />
</intent-filter>
Previous answers are OK but don't forget to specify the pattern.
See more details here.
Also define your hostname inside Gradle file like:
android {
defaultConfig {
manifestPlaceholders = [hostName:"subdomain.example.com"]
}
}
More info about manifestPlaceholders here.
Im trying to register a protocol in my app whereby a url executed in the android browser will launch my activity, all the examples Ive seen on the web say to add an Intent Filter on my activity such as
<activity android:name=".UrlActivity">
<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="myscheme" android:host="myhost"/>
</intent-filter>
</activity>`
but this doesnt seem to be enough to get the Android OS to launch my activity...
Is there anyone who could tell me if there is something Im missing?
Thanks
Try removing theandroid:host part, but retain the android:scheme attribute.
Also check logcat for any errors or warnings.
The URL has to be made available as a hyperlink on a page for the user to tap. Entering the URL in a browser on your device will not work. This resolved the problem for me.