Question

I want to know how to check if an android default browser or any mobile browser is already running. Can I also check if my url (e.g."www.url.com") is accessed? Or can I get url?

thanks.

Was it helpful?

Solution

I want to know how to check if an android default browser or any mobile browser is already running.

You can use ActivityManager to check which tasks are running. Example:

 ActivityManager actvityManager = (ActivityManager) youContext.getSystemService( ACTIVITY_SERVICE );
 List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses();
 for(int i = 0; i < procInfos.size(); i++)
 {
     if(procInfos.get(i).processName.equals("com.android.browser")) {
         Toast.makeText(getApplicationContext(), "Browser App is running", Toast.LENGTH_LONG).show();
     }
 }

You can have a list of the process names you want to check if they are running. For the above example i used the default Android Browser.

Source: https://stackoverflow.com/a/11391558/1482726

Can I also check if my url (e.g."www.url.com") is accessed? Or can I get url?

I do not think that is possible.

OTHER TIPS

This is impossible. The android browser or any other browser (the user may have another default browser) does not emit any broadcast when an url is opened.

A possible solution is to write your own browser.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top