Get url from android browser - android

is it possible to get callback whenever a url is opened from the android browser.
getallvisitedurls() method returns just url, I want it in realtime and with timestamp of the access.

This is not possible. The Android Browser does not emit a broadcast or anything like that whenever the user opens a URL in it. Besides, the user may be using a third party browser instead of the default one.
The only way you could do this is by making your own browser app and have the user use that one instead of the default browser that came with their ROM.

I believe it is possible to do so by using retrieveRequestToken.
The Twitter API returns a callback for OAuth, so I think it would be possible.
Have a look at this post. It explains how it is to be done and it sounds all good to me.
Note : I haven't tried it myself. So no guarantees. :)

Related

How to avoid hardcoded urls in IOS/Android app

I'm developing a django web-project and I'm going to develop its IOS and Android API.
Is there a way to avoid using hardcoded url addresses in the app code?Something like django url name system
The following problem faces me if there isn't any solution to my question:
If I want to change some of my urls, I should change the app code and also all the previous installed apps on peoples' devices won't work and should be updated.
The way I see it, you probably have two options:
a) Code very generic forwarding links into your app, such as:
http://www.example.com?linkid=1
http://www.example.com?linkid=2
You can then, from your side, forward these on to where you need them to go by using the query string ID number.
b) Write a web service to push updated URLs to your app, maybe on load so you're not polling the service all the time.
How often are the URLs likely to change?

GroupMe API Callback

So, I am trying to use GroupMe's API. The issue is that I don't really know how to get the users access_token once I send them to the site to login. I don't really know how to create a callback or how to use it. So to sum it up
I need to send users to this site
https://oauth.groupme.com/oauth/authorize?client_id=CLIENT_ID,
then they login and groupme sends them to here
https://YOUR_CALLBACK_URL/?access_token=ACCESS_TOKEN.
But I don't know how/where to create a callback url. Then I don't know how to send that access_token back to the app.
Thanks.
A callback URL is simply a url exposed by your app that groupme can redirect users to. The page can be anything, however, oftentimes it takes the user back to your app if it is a webapp, or tells the user to close the page.
The important part is that the url is one that the app controls, so that it can get the contents of the url that contain the token and other data.
If you are writing a web app, then the framework or language should a method or variable you can call or read to get the url. If you are writing a desktop/moble app, one way of creating a callback url is to listen on a tcp port and speak http to the browser. Another way is using a lightweight web server library, or use a lightweight external server like lighthttp and communicate using cgi/fastcgi. All that matters is that you can get the url that groupme se,t the user to.
If you need anymore help, you are using Oauth2 so search for help with that. Nothing that you asked about here is specfic to groupme, so you should be able to use any OAuth2 library.

Detect and append POST parameters in Android WebView

I am developing an app for Android that relies heavily on internet content. In the app I have a WebView that lets the user browse our secure website. This is working great. However some times we need to trigger a method in our native app.
To do this we need to intercept a POST request when the user submits a form, look for a specific parameter, and if the parameter is there, append another parameter to the POST request before submitting it.
It is important that our app supports older APIs. At least API level 8. In iOS this was a piece of cake. We just intercepted the URL reques and appended our url encoded parameter. In Android however it is much harder. I am unable to find a way to intercept the request without making any changes to our website.
I have tried overriding the webviews loadUrl() method and postUrl() method, but it seems they are not called when the user interacts with a href in the webview. The specific parameter we are looking for can come from different urls, so it is not enought to override the url itself or hardcode the form name. I hope someone is able to help me with this problem.
You can use javascript to intercept the posting. As you can validate all inputs with javascript you can also set up all key=value pairs. The javascript itself can only execute a get request. If that is not allowed use an android javascript bridge to execute a post.
Check out the WebViewClient http://developer.android.com/reference/android/webkit/WebView.html#setWebViewClient(android.webkit.WebViewClient) for the webview.
Using this you can handle all the request going through your webview.

How can I prevent an Android WebView from manipulating a web page?

As shown here it is possible to:
1. Create an Android WebView with setJavaScriptEnabled=true
2. Load a URL
3. Override onPageFinished and change the Web page displayed to the user
Now, is it possible for the Web page owner to implement anything server-side which prevents this from happening? The risk is that a malicious app could spoof the user by amending the Web page for nefarious means...
Many thanks!
It is not really possible to prevent the web response being modified. You can only think of making it difficult for the spoofer to edit it.

Passing data from Android Browser to external app

This is what I need to do:
I have an app running in the background. Now when the user is browsing and comes across an 'interesting' URL, he can make a gesture and send the URL to the external app. The app then processes it.
I can think of two way of doing this(though I am not sure if either is possible)
1. Program something like a hook that senses the particular gesture or key press and sends the URL to the app
Write something like an add on to the browser.
My question is, is any of this possible. If yes, could you give me a few hints so that I can go ahead. If not, then is there any other way to do it?
Thanks,
Sandip
Short answer : You can't use the android browser like this.
Long answer : The android browser is an application. The only way you can interact with it is to call it with an argument (a URL). And... that's all. You can't write an extension to the browser like you can do in Chrome.
If you want to control the browser, use a webview, but even in that case, you won't have the ability to detect gesture.
What you're trying to do is not possible.
Take a look at WebViewClient.shouldOverrideUrlLoading. It should allow you to be notified when a new URL is loaded.
http://developer.android.com/reference/android/webkit/WebViewClient.html#shouldOverrideUrlLoading%28android.webkit.WebView,%20java.lang.String%29

Categories

Resources