1

im wandering if its technically possible to check whether an android user browses some particular site. I would like to detect if with my own app. Im trying with:

     <intent-filter>
        <action android:name="android.intent.action.VIEW"></action>  
        <category android:name="android.intent.category.DEFAULT"></category>  
        <category android:name="android.intent.category.BROWSABLE"></category>  
        <data android:scheme="http" android:host="mysamplepage.com"></data>  
    </intent-filter>

but i cant get any results.

I know that this kind of approach works, because my OAuth client makes this kind of callback to my app. Although im unable to launch my activity from the address bar with the address.

Any suggestions?

Lukas
  • 455
  • 4
  • 11

1 Answers1

0

You can use a webview client to detect if your webview makes a request

final WebView webView;
webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(loginUrl);
webView.setWebViewClient(new WebViewClient()
{

@Override
public void onPageFinished(WebView view, String url)
{
 if (url.contains("YOUR_DESIRED_URL_TO_TRACK"))
 {
        Log.v(TAG, "Voila!");
 }
}
});
Yekmer Simsek
  • 4,102
  • 3
  • 21
  • 19
  • The reason why I tried with intent filters is that I want to check if the user visited some adress without having my activity alive. So either with intent filters (activity would be started), broadcasts (?) or geting a browser history in scheduled alarms. I didnt manage to get any of this ideas to work though. Any suggestions? – Lukas Apr 03 '11 at 19:41
  • I think you can not do this as every application lives in a sandbox. But you can read browser history as seen here http://stackoverflow.com/questions/2577084/android-read-browser-history – Yekmer Simsek Apr 04 '11 at 06:26