[android-developers] Retrieving current URL from chrome (or browser). Use ContentProvider? Or, other method?
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
Re: [android-developers] Retrieving current URL from chrome (or browser). Use ContentProvider? Or, other method?
On Wed, Jan 16, 2013 at 1:02 PM, xrd xrdaw...@gmail.com wrote: Is there a way to retrieve the URL for the current webpage in Chrome in another fashion? AFAIK, there is no documented and supported API for the Chrome browser app. Fortunately, I also do not see any obvious script kiddie approach, either. 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? AFAIK, Chrome does not use that ContentProvider. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 4.5 Available! -- 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
Re: [android-developers] Retrieving current URL from chrome (or browser). Use ContentProvider? Or, other method?
Yes.. You probably won't be able to make this work. Additionally, the get history permission no longer works either. Kris On Jan 16, 2013 12:04 PM, xrd xrdaw...@gmail.com wrote: 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 -- 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