本文介绍了Browser.EXTRA_APPLICATION_ID不要在片剂工作。你知道其他变通重用Browser.apk的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

EXTRA_APPLICATION_ID似乎没有在平板电脑工作。你知不知道其他的工作由我服务的意图启动浏览器时,周围重用Browser.apk的标签。这直接关系到9902225.任何提示是AP preciated。

原因:resuseTab()如果设备是平板电脑将不能称作

请参阅行:

  * 3片)打开新标签

请参阅行:

 如果(activateVoiceSearch ||!BrowserActivity.isTablet(mActivity)){

// Browser.apk源$ C ​​$ C(Android版4.0.3_r1-6)

  com.android.browser.IntentHandler无效onNewIntent(意向意图){
....
   / *
     * TODO:不允许的JavaScript的URI
     * 0)。如果这是一个javascript:URI,*总是*打开一个新标签
     * 1)如果这是一个APPID语音搜索,再利用标签
     *如果没有的appid,使用当前选项卡
     * 2)如果URL已打开,切换到该标签
     * 3手机)用相同的appid重复利用标签
     * 3片)打开新标签
     * /
    最后弦乐的appid =意图
            .getStringExtra(Browser.EXTRA_APPLICATION_ID);
    如果(TextUtils.isEmpty(urlData.mUrl)及!&安培;
            urlData.mUrl.startsWith(JavaScript的:)){
        //始终打开的javascript:在新标签的URI
        mController.openTab(urlData);
        返回;
    }
    如果((Intent.ACTION_VIEW.equals(动作)
            //如果语音搜索没有APPID,这意味着它来了
            //从浏览器。在这种情况下,重复使用当前的标签。
            || (activateVoiceSearch&安培;&安培;!APPID = NULL))
            &功放;&安培; !mActivity.getPackageName()。等于(APPID)){
        如果(activateVoiceSearch ||!BrowserActivity.isTablet(mActivity)){
            标签appTab = mTab​​Control.getTabFromAppId(APPID);
            如果(appTab!= NULL){
                mController.reuseTab(appTab,urlData);
                返回;
            }
        }
        //没有匹配的应用程序选项卡上,尽量找正规标签
        具有匹配URL //。
        标签appTab = mTab​​Control.findTabWith​​Url(urlData.mUrl);
        如果(appTab!= NULL){
            //转移所有权
            appTab.setAppId(APPID);
            如果(电流!= appTab){
                mController.switchToTab(appTab);
            }
            //否则,我们已经观看了正确的选项卡。
        }其他{
            //如果FLAG_ACTIVITY_BROUGHT_TO_FRONT标志时,该网址
            //将在新标签中打开,除非我们已经达到
            // MAX_TABS。那么URL将在当前被打开
            // 标签。如果创建一个新的标签,就会有真为
            //关闭时退出。
            TAB键的话= mController.openTab(urlData);
            如果(标签!= NULL){
                tab.setAppId(APPID);
                如果((intent.getFlags()及!Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)= 0){
                    tab.setCloseOnBack(真);
                }
            }
        }


解决方案

有关ICS和平板设备,你需要设置的意图的App ID作为浏览器的应用程序ID。
所以,你需要使用 com.android.browser 而不是 getPackageName()

EXTRA_APPLICATION_ID seems not to work in the tablet. Do you know other work around to reuse tab of the Browser.apk when starting the Browser by intent from my service. This is directly related to 9902225. Any hints is appreciated.

Cause: The resuseTab() will not be called if the device is a tablet.

See line:

* 3-tablet) Open new tab

See line:

if (activateVoiceSearch || !BrowserActivity.isTablet(mActivity)) {

// Browser.apk source code (Android 4.0.3_r1-6)

com.android.browser.IntentHandler

void onNewIntent(Intent intent) {
....
   /*
     * TODO: Don't allow javascript URIs
     * 0) If this is a javascript: URI, *always* open a new tab
     * 1) If this is a voice search, re-use tab for appId
     *    If there is no appId, use current tab
     * 2) If the URL is already opened, switch to that tab
     * 3-phone) Reuse tab with same appId
     * 3-tablet) Open new tab
     */
    final String appId = intent
            .getStringExtra(Browser.EXTRA_APPLICATION_ID);
    if (!TextUtils.isEmpty(urlData.mUrl) &&
            urlData.mUrl.startsWith("javascript:")) {
        // Always open javascript: URIs in new tabs
        mController.openTab(urlData);
        return;
    }
    if ((Intent.ACTION_VIEW.equals(action)
            // If a voice search has no appId, it means that it came
            // from the browser.  In that case, reuse the current tab.
            || (activateVoiceSearch && appId != null))
            && !mActivity.getPackageName().equals(appId)) {
        if (activateVoiceSearch || !BrowserActivity.isTablet(mActivity)) {
            Tab appTab = mTabControl.getTabFromAppId(appId);
            if (appTab != null) {
                mController.reuseTab(appTab, urlData);
                return;
            }
        }
        // No matching application tab, try to find a regular tab
        // with a matching url.
        Tab appTab = mTabControl.findTabWithUrl(urlData.mUrl);
        if (appTab != null) {
            // Transfer ownership
            appTab.setAppId(appId);
            if (current != appTab) {
                mController.switchToTab(appTab);
            }
            // Otherwise, we are already viewing the correct tab.
        } else {
            // if FLAG_ACTIVITY_BROUGHT_TO_FRONT flag is on, the url
            // will be opened in a new tab unless we have reached
            // MAX_TABS. Then the url will be opened in the current
            // tab. If a new tab is created, it will have "true" for
            // exit on close.
            Tab tab = mController.openTab(urlData);
            if (tab != null) {
                tab.setAppId(appId);
                if ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
                    tab.setCloseOnBack(true);
                }
            }
        }
解决方案

For ICS and tablet devices, you need to set the intent's App ID as the browser's App ID.So you need to use com.android.browser instead of getPackageName()

这篇关于Browser.EXTRA_APPLICATION_ID不要在片剂工作。你知道其他变通重用Browser.apk的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 15:25