How to Avoid Loading Local Page in New Tab on Default Android Browser

≯℡__Kan透↙ 提交于 2019-12-08 08:39:07

问题


I want to do the opposite of this: Android Browser: open several URLs, each on new window/tab (programmatically)

In there, the answer was to use b.putBoolean("new_window", true); but what is the equivalent for same tab or same window?

For some reason I'm only having this issue on tablets (tested on 3.1 and 4.0.3). We open URLs correctly on the same window or same tab on phones.

Please don't tell me to use a webview, what I'm trying to do is do things in the background while a user is browsing on the default Android browser.

Thanks.


回答1:


Okay I found the fix. Basically, phones running 2.3 and lower use com.android.browser, with activity name com.android.browser.BrowserActivity. I believe in 3.0, ApplicationIDs were introduced.

Tablets still use the same Browser package name, but has an ApplicationID of com.android.browser, while ICS 4.0.2+ uses com.google.android.browser as the package name, and com.google.android.browser as the appId (same Activity name is used). So I just had to add that into my BrowserData.

After this, one must use the EXTRA_APPLICATION_ID flag on their browser intent to avoid the automatic opening of a new tab. More on that here: http://developer.android.com/reference/android/provider/Browser.html



来源:https://stackoverflow.com/questions/9221725/how-to-avoid-loading-local-page-in-new-tab-on-default-android-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!