I am searching ways of working with Android Standard Browser from my own
application. First of all I want to know is there a way to refresh last
opened tag in the Standard Android Browser by sending some intent from the
own application or something else, I try do do that using this code, but it
doesn't work
private static final String PACKAGE_BROWSER = "com.android.browser";
private static final String PACKAGE_BROWSER_GOOGLE =
"com.google.android.browser";
private void launchBrowser(){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TOP);
String browserPackage = getBrowserPackage();
Uri yourUri = Uri.parse("www.google.com");
intent.setDataAndType(yourUri, "text/html");
intent.setComponent(new ComponentName(browserPackage,
"com.android.browser.BrowserActivity"));
startActivity(intent);
}
private String getBrowserPackage(){
PackageManager pm = context.getPackageManager();
PackageInfo packageInfo = null;
try {
packageInfo = pm.getPackageInfo(PACKAGE_BROWSER, 0);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
if(packageInfo==null){
return PACKAGE_BROWSER_GOOGLE;
}else{
return PACKAGE_BROWSER;
}
}
The hole problem that I want to solve is a detection of is my own
application is installed on a phone when user press on a link in a Standard
Android Browser.I know that this problem has no trivial solution, or maybe
it have no solution at all, but I am trying to understand why there is no
solution.
No I am on a point when by clicking on a browser link I open my application
if it is installed on a phone and if it is not installed I open an Android
play store page in a browser, using this
<https://gist.github.com/2662899>example
. But this example have some bat side as it always open Android Play Store
in the browser only if my application exist in a phone it opens it first
and then user press back in application and he can see how on a browser
Android Store is loading.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en