I'm trying to get access to the current URL on the chrome browser. I want 
my service to perform a task when it recognizes the user is on a specific 
web page.

I've been able to retrieve the name of current application ("Chrome") using 
a combination of the android.permission.GET_TASKS permission and this code. 
However, this just gives me the name of the application, and not the URL. 

ActivityManager am = (ActivityManager) 
getSystemService(Activity.ACTIVITY_SERVICE); 
String packageName = 
am.getRunningTasks(1).get(0).topActivity.getPackageName(); 
PackageManager pm = getPackageManager(); 
try { 
CharSequence c = pm.getApplicationLabel(pm.getApplicationInfo(packageName, 
PackageManager.GET_META_DATA)); 
currentAppName = c.toString(); 
}
catch (Exception e) {}

Is there a way to retrieve the URL for the current webpage in Chrome in 
another fashion?

I don't see that ContentProvider for browser provides anything with respect 
to the current URL. Would the last item in the history 
*(getAllVisitedUrls(...)) 
*tell me this?

Or, is there another way to query this information from the browser 
directly?

I don't need to do this in a sneaky way, I want the user to be fully aware 
that I am asking for this information.

Thanks,
Chris

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to