Browser设置搜索引擎

Browser设置搜索引擎,在com.android.browser.preferences.GeneralPreferencesFragment中加载R.xml.general_preferences。

看看general_preferences.xml

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

    <PreferenceCategory android:title="@string/pref_general_title">
        <com.android.browser.preferences.NonformattingListPreference
            android:key="homepage_picker"
            android:entries="@array/pref_homepage_choices"
            android:entryValues="@array/pref_homepage_values"
            android:title="@string/pref_content_homepage" />

        <com.android.browser.search.SearchEnginePreference
       android:defaultValue="@string/default_search_engine_value"
            android:dialogTitle="@string/pref_content_search_engine"
            android:key="search_engine"
            android:summary="@string/pref_content_search_engine_summary"
            android:title="@string/pref_content_search_engine" />

SearchEnginePreference来显示引擎列表,SearchEngines.getSearchEngineInfos(context)获取引擎

    //SearchEngines获取引擎列表  public static List<SearchEngineInfo> getSearchEngineInfos(Context context) {
        ArrayList<SearchEngineInfo> searchEngineInfos = new ArrayList<SearchEngineInfo>();
        String[] searchEngines = context.getResources().getStringArray(R.array.search_engines);
        for (int i = 0; i < searchEngines.length; i++) {
            String name = searchEngines[i];
            SearchEngineInfo info = new SearchEngineInfo(context, name);
            searchEngineInfos.add(info);
        }
        return searchEngineInfos;
    }

Browser中所有的引擎列表在values/all_search_engines.xml中配置。R.array.search_engines配置要显示的引擎。

all_search_engines.xml

<resources>
  <string-array name="DuckDuckGo" translatable="false">
    <item>DuckDuckGo</item>
    <item>duckduckgo.com</item>
    <item>http://duckduckgo.com/favicon.ico</item>
    <item>https://duckduckgo.com/?q={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="yahoo_uk" translatable="false">
    <item>Yahoo! UK &amp; Ireland</item>
    <item>uk.yahoo.com</item>
    <item>http://uk.search.yahoo.com/favicon.ico</item>
    <item>http://uk.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://uk-sayt.ff.search.yahoo.com/gossip-uk-sayt?output=fxjson&amp;command={searchTerms}</item>
  </string-array>
  <string-array name="yahoo_jp" translatable="false">
    <item>Yahoo! JAPAN</item>
    <item>yahoo.co.jp</item>
    <item>http://search.yahoo.co.jp/favicon.ico</item>
    <item>http://search.yahoo.co.jp/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="rambler" translatable="false">
    <item>Rambler</item>
    <item>rambler.ru</item>
    <item>http://www.rambler.ru/favicon.ico</item>
    <item>http://www.rambler.ru/srch?words={searchTerms}</item>
    <item>windows-1251</item>
    <item></item>
  </string-array>
  <string-array name="yahoo_br" translatable="false">
    <item>Yahoo! Brasil</item>
    <item>br.yahoo.com</item>
    <item>http://br.search.yahoo.com/favicon.ico</item>
    <item>http://br.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://br-sayt.ff.search.yahoo.com/gossip-br-sayt?output=fxjson&amp;command={searchTerms}</item>
  </string-array>
  <string-array name="bing_zh_HK" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=zh-HK&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing_el_GR" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=el-GR&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing_tr_TR" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=tr-TR&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="ask_uk" translatable="false">
    <item>Ask Jeeves</item>
    <item>uk.ask.com</item>
    <item>http://uk.ask.com/favicon.ico</item>
    <item>http://uk.ask.com/web?q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://ss.uk.ask.com/query?q={searchTerms}&amp;li=ff</item>
  </string-array>
  <string-array name="nate" translatable="false">
    <item>네이트닷컴</item>
    <item>nate.com</item>
    <item>http://nate.search.empas.com/favicon.ico</item>
    <item>http://nate.search.empas.com/search/all.html?q={searchTerms}</item>
    <item>EUC-KR</item>
    <item></item>
  </string-array>
  <string-array name="uol" translatable="false">
    <item>UOL Busca</item>
    <item>busca.uol.com.br</item>
    <item>http://busca.uol.com.br/favicon.ico</item>
    <item>http://busca.uol.com.br/www/index.html?q={searchTerms}</item>
    <item>ISO-8859-1</item>
    <item></item>
  </string-array>
  <string-array name="baidu_cn" translatable="false">
    <item>百度</item>
    <item>baidu.com</item>
    <item>http://www.baidu.com/favicon.ico</item>
    <item>http://www.baidu.com/s?wd={searchTerms}</item>
    <item>GB2312</item>
    <item></item>
  </string-array>
  <string-array name="baidu" translatable="false">
    <item>Baidu</item>
    <item>baidu.com</item>
    <item>http://www.baidu.com/favicon.ico</item>
    <item>http://www.baidu.com/s?wd={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="yahoo_ch" translatable="false">
    <item>Yahoo! Suche</item>
    <item>ch.yahoo.com</item>
    <item>http://ch.search.yahoo.com/favicon.ico</item>
    <item>http://ch.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="bing_nl_BE" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=nl-BE&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="yahoo_cn" translatable="false">
    <item>中国雅虎</item>
    <item>cn.yahoo.com</item>
    <item>http://sg.search.yahoo.com/favicon.ico</item>
    <item>http://sg.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="onet" translatable="false">
    <item>Onet.pl</item>
    <item>onet.pl</item>
    <item>http://szukaj.onet.pl/favicon.ico</item>
    <item>http://szukaj.onet.pl/query.html?qt={searchTerms}</item>
    <item>ISO-8859-2</item>
    <item></item>
  </string-array>
  <string-array name="ask_es" translatable="false">
    <item>Ask.com España</item>
    <item>es.ask.com</item>
    <item>http://es.ask.com/favicon.ico</item>
    <item>http://es.ask.com/web?q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://ss.es.ask.com/query?q={searchTerms}&amp;li=ff</item>
  </string-array>
  <string-array name="bing_cs_CZ" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=cs-CZ&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="altavista_se" translatable="false">
    <item>AltaVista</item>
    <item>se.altavista.com</item>
    <item>http://se.altavista.com/favicon.ico</item>
    <item>http://se.altavista.com/web/results?q={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="mail_ru" translatable="false">
    <item>\@MAIL.RU</item>
    <item>mail.ru</item>
    <item>http://img.go.mail.ru/favicon.ico</item>
    <item>http://go.mail.ru/search?q={searchTerms}</item>
    <item>windows-1251</item>
    <item></item>
  </string-array>
  <string-array name="hispavista" translatable="false">
    <item>hispavista</item>
    <item>hispavista.com</item>
    <item>http://buscar.hispavista.com/favicon.ico</item>
    <item>http://buscar.hispavista.com/?cadena={searchTerms}</item>
    <item>iso-8859-1</item>
    <item></item>
  </string-array>
  <string-array name="bing_zh_CN" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=zh-CN&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="google" translatable="false">
    <item>Google</item>
    <item>google.com</item>
    <item>https://www.google.com/favicon.ico</item>
    <item>https://www.google.com/search?ie={inputEncoding}&amp;source=android-browser&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>https://www.google.com/complete/search?client=android&amp;q={searchTerms}</item>
  </string-array>
  <string-array name="bing_en_NZ" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=en-NZ&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing_fr_BE" translatable="false">
    <item>Bing</item>
    <item></item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=fr-BE&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="rednano" translatable="false">
    <item>Rednano</item>
    <item>rednano.sg</item>
    <item>http://rednano.sg/favicon.ico</item>
    <item>http://rednano.sg/sfe/lwi.action?querystring={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="goo" translatable="false">
    <item>goo</item>
    <item>search.goo.ne.jp</item>
    <item>http://goo.ne.jp/favicon.ico</item>
    <item>http://search.goo.ne.jp/web.jsp?MT={searchTerms}&amp;IE={inputEncoding}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="sapo" translatable="false">
    <item>SAPO</item>
    <item>sapo.pt</item>
    <item>http://imgs.sapo.pt/images/sapo.ico</item>
    <item>http://pesquisa.sapo.pt/?q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://pesquisa.sapo.pt/livesapo?q={searchTerms}</item>
  </string-array>
  <string-array name="bing_it_IT" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=it-IT&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing_es_ES" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=es-ES&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="abcsok" translatable="false">
    <item>ABC Søk</item>
    <item>abcsok.no</item>
    <item>http://abcsok.no/favicon.ico</item>
    <item>http://abcsok.no/index.html?q={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="yahoo_dk" translatable="false">
    <item>Yahoo! Danmark</item>
    <item>dk.yahoo.com</item>
    <item>http://dk.search.yahoo.com/favicon.ico</item>
    <item>http://dk.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="yahoo_de" translatable="false">
    <item>Yahoo! Deutschland</item>
    <item>de.yahoo.com</item>
    <item>http://de.search.yahoo.com/favicon.ico</item>
    <item>http://de.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://de-sayt.ff.search.yahoo.com/gossip-de-sayt?output=fxjson&amp;command={searchTerms}</item>
  </string-array>
  <string-array name="bing_de_AT" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=de-AT&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing_pl_PL" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=pl-PL&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="tut" translatable="false">
    <item>TUT.BY</item>
    <item>tut.by</item>
    <item>http://www.tut.by/favicon.ico</item>
    <item>http://search.tut.by/?query={searchTerms}</item>
    <item>windows-1251</item>
    <item></item>
  </string-array>
  <string-array name="spray" translatable="false">
    <item>Spray</item>
    <item>spray.se</item>
    <item>http://www.eniro.se/favicon.ico</item>
    <item>http://www.eniro.se/query?ax=spray&amp;search_word={searchTerms}&amp;what=web</item>
    <item>ISO-8859-1</item>
    <item></item>
  </string-array>
  <string-array name="wp" translatable="false">
    <item>Wirtualna Polska</item>
    <item>wp.pl</item>
    <item>http://szukaj.wp.pl/favicon.ico</item>
    <item>http://szukaj.wp.pl/szukaj.html?szukaj={searchTerms}</item>
    <item>ISO-8859-2</item>
    <item></item>
  </string-array>
  <string-array name="yahoo_tw" translatable="false">
    <item>Yahoo!奇摩</item>
    <item>tw.yahoo.com</item>
    <item>http://tw.search.yahoo.com/favicon.ico</item>
    <item>http://tw.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="atlas_cz" translatable="false">
    <item>Atlas</item>
    <item>atlas.cz</item>
    <item>http://img.atlas.cz/favicon.ico</item>
    <item>http://search.atlas.cz/?q={searchTerms}</item>
    <item>windows-1250</item>
    <item></item>
  </string-array>
  <string-array name="bing_en_GB" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=en-GB&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="yahoo_es" translatable="false">
    <item>Yahoo! España</item>
    <item>es.yahoo.com</item>
    <item>http://es.search.yahoo.com/favicon.ico</item>
    <item>http://es.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://es-sayt.ff.search.yahoo.com/gossip-es-sayt?output=fxjson&amp;command={searchTerms}</item>
  </string-array>
  <string-array name="libero" translatable="false">
    <item>Libero</item>
    <item>libero.it</item>
    <item>http://arianna.libero.it/favicon.ico</item>
    <item>http://arianna.libero.it/search/abin/integrata.cgi?query={searchTerms}</item>
    <item>ISO-8859-1</item>
    <item></item>
  </string-array>
  <string-array name="bing_sv_SE" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=sv-SE&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="yahoo_nz" translatable="false">
    <item>Yahoo!Xtra</item>
    <item>nz.yahoo.com</item>
    <item>http://nz.search.yahoo.com/favicon.ico</item>
    <item>http://nz.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://aue-sayt.ff.search.yahoo.com/gossip-nz-sayt?output=fxjson&amp;command={searchTerms}</item>
  </string-array>
  <string-array name="terra_es" translatable="false">
    <item>Terra</item>
    <item>terra.es</item>
    <item>http://buscador.terra.es/favicon.ico</item>
    <item>http://buscador.terra.es/Default.aspx?query={searchTerms}&amp;source=Search</item>
    <item>ISO-8859-1</item>
    <item></item>
  </string-array>
  <string-array name="yahoo_nl" translatable="false">
    <item>Yahoo! Nederland</item>
    <item>nl.yahoo.com</item>
    <item>http://nl.search.yahoo.com/favicon.ico</item>
    <item>http://nl.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="yahoo_no" translatable="false">
    <item>Yahoo! Norge</item>
    <item>no.yahoo.com</item>
    <item>http://no.search.yahoo.com/favicon.ico</item>
    <item>http://no.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="daum" translatable="false">
    <item>Daum</item>
    <item>daum.net</item>
    <item>http://search.daum.net/favicon.ico</item>
    <item>http://search.daum.net/search?q={searchTerms}</item>
    <item>EUC-KR</item>
    <item>http://sug.search.daum.net/search_nsuggest?mod=fxjson&amp;q={searchTerms}</item>
  </string-array>
  <string-array name="yahoo_fr" translatable="false">
    <item>Yahoo! France</item>
    <item>fr.yahoo.com</item>
    <item>http://fr.search.yahoo.com/favicon.ico</item>
    <item>http://fr.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://fr-sayt.ff.search.yahoo.com/gossip-fr-sayt?output=fxjson&amp;command={searchTerms}</item>
  </string-array>
  <string-array name="ask_nl" translatable="false">
    <item>Ask.com Nederland</item>
    <item>nl.ask.com</item>
    <item>http://nl.ask.com/favicon.ico</item>
    <item>http://nl.ask.com/web?q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://ss.nl.ask.com/query?q={searchTerms}&amp;li=ff</item>
  </string-array>
  <string-array name="seznam" translatable="false">
    <item>Seznam</item>
    <item>seznam.cz</item>
    <item>http://1.im.cz/szn/img/favicon.ico</item>
    <item>http://search.seznam.cz/?q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://suggest.fulltext.seznam.cz/?dict=fulltext_ff&amp;phrase={searchTerms}&amp;encoding={inputEncoding}&amp;response_encoding=utf-8</item>
  </string-array>
  <string-array name="centrum_cz" translatable="false">
    <item>Centrum.cz</item>
    <item>centrum.cz</item>
    <item>http://img.centrum.cz/6/vy2/o/favicon.ico</item>
    <item>http://search.centrum.cz/index.php?charset={inputEncoding}&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="eniro_se" translatable="false">
    <item>Eniro</item>
    <item>eniro.se</item>
    <item>http://eniro.se/favicon.ico</item>
    <item>http://eniro.se/query?search_word={searchTerms}&amp;what=web_local</item>
    <item>ISO-8859-1</item>
    <item></item>
  </string-array>
  <string-array name="kvasir" translatable="false">
    <item>Kvasir</item>
    <item>kvasir.no</item>
    <item>http://www.kvasir.no/img/favicon.ico</item>
    <item>http://www.kvasir.no/nettsok/searchResult.html?searchExpr={searchTerms}</item>
    <item>ISO-8859-1</item>
    <item></item>
  </string-array>
  <string-array name="yahoo" translatable="false">
    <item>Yahoo!</item>
    <item>yahoo.com</item>
    <item>http://search.yahoo.com/favicon.ico</item>
    <item>http://search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://ff.search.yahoo.com/gossip?output=fxjson&amp;command={searchTerms}</item>
  </string-array>
  <string-array name="bing_en_IE" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=en-IE&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing_pt_PT" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=pt-PT&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing_de_CH" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=de-CH&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing_nl_NL" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=nl-NL&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing_fr_CH" translatable="false">
    <item>Bing</item>
    <item></item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=fr-CH&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing_zh_TW" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=zh-TW&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing_ru_RU" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=ru-RU&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing_en_AU" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=en-AU&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing_da_DK" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=da-DK&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="ask_it" translatable="false">
    <item>Ask.com Italia</item>
    <item>it.ask.com</item>
    <item>http://it.ask.com/favicon.ico</item>
    <item>http://it.ask.com/web?q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://ss.it.ask.com/query?q={searchTerms}&amp;li=ff</item>
  </string-array>
  <string-array name="yandex_ru" translatable="false">
    <item>Яндекс</item>
    <item>yandex.ru</item>
    <item>http://yandex.ru/favicon.ico</item>
    <item>http://yandex.ru/yandsearch?text={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://suggest.yandex.net/suggest-ff.cgi?part={searchTerms}</item>
  </string-array>
  <string-array name="bing_ja_JP" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=ja-JP&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="yahoo_kr" translatable="false">
    <item>야후! 코리아</item>
    <item>kr.yahoo.com</item>
    <item>http://kr.search.yahoo.com/favicon.ico</item>
    <item>http://kr.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://kr.atc.search.yahoo.com/atcx.php?property=main&amp;ot=fxjson&amp;ei=utf8&amp;eo=utf8&amp;command={searchTerms}</item>
  </string-array>
  <string-array name="ask_de" translatable="false">
    <item>Ask.com Deutschland</item>
    <item>de.ask.com</item>
    <item>http://de.ask.com/favicon.ico</item>
    <item>http://de.ask.com/web?q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://ss.de.ask.com/query?q={searchTerms}&amp;li=ff</item>
  </string-array>
  <string-array name="yahoo_hk" translatable="false">
    <item>Yahoo! Hong Kong</item>
    <item>hk.yahoo.com</item>
    <item>http://hk.search.yahoo.com/favicon.ico</item>
    <item>http://hk.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="bing_fr_FR" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=fr-FR&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="in" translatable="false">
    <item>in.gr</item>
    <item>in.gr</item>
    <item>http://www.in.gr/favicon.ico</item>
    <item>http://find.in.gr/?qs={searchTerms}</item>
    <item>ISO-8859-7</item>
    <item></item>
  </string-array>
  <string-array name="bing_nb_NO" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=nb-NO&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="yahoo_sg" translatable="false">
    <item>Yahoo! Singapore</item>
    <item>sg.yahoo.com</item>
    <item>http://sg.search.yahoo.com/favicon.ico</item>
    <item>http://sg.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://sg-sayt.ff.search.yahoo.com/gossip-sg-sayt?output=fxjson&amp;command={searchTerms}</item>
  </string-array>
  <string-array name="yahoo_se" translatable="false">
    <item>Yahoo! Sverige</item>
    <item>se.yahoo.com</item>
    <item>http://se.search.yahoo.com/favicon.ico</item>
    <item>http://se.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="bing_de_DE" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=de-DE&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="search_de_CH" translatable="false">
    <item>search.ch</item>
    <item>search.ch</item>
    <item>http://www.search.ch/favicon.ico</item>
    <item>http://www.search.ch/index.de.html?q={searchTerms}</item>
    <item>ISO-8859-1</item>
    <item></item>
  </string-array>
  <string-array name="mynet" translatable="false">
    <item>MYNET</item>
    <item>mynet.com</item>
    <item>http://img.mynet.com/mynetfavori.ico</item>
    <item>http://arama.mynet.com/search.aspx?q={searchTerms}&amp;pg=q</item>
    <item>windows-1254</item>
    <item></item>
  </string-array>
  <string-array name="search_fr_CH" translatable="false">
    <item>search.ch</item>
    <item></item>
    <item>http://www.search.ch/favicon.ico</item>
    <item>http://www.search.ch/index.fr.html?q={searchTerms}</item>
    <item>ISO-8859-1</item>
    <item></item>
  </string-array>
  <string-array name="virgilio" translatable="false">
    <item>Virgilio</item>
    <item>virgilio.it</item>
    <item>http://ricerca.alice.it/favicon.ico</item>
    <item>http://ricerca.alice.it/ricerca?qs={searchTerms}</item>
    <item>ISO-8859-1</item>
    <item></item>
  </string-array>
  <string-array name="bing_en_SG" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=en-SG&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="yahoo_it" translatable="false">
    <item>Yahoo! Italia</item>
    <item>it.yahoo.com</item>
    <item>http://it.search.yahoo.com/favicon.ico</item>
    <item>http://it.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://it-sayt.ff.search.yahoo.com/gossip-it-sayt?output=fxjson&amp;command={searchTerms}</item>
  </string-array>
  <string-array name="yahoo_at" translatable="false">
    <item>Yahoo! Suche</item>
    <item>at.yahoo.com</item>
    <item>http://at.search.yahoo.com/favicon.ico</item>
    <item>http://at.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="yahoo_au" translatable="false">
    <item>Yahoo!7</item>
    <item>au.yahoo.com</item>
    <item>http://au.search.yahoo.com/favicon.ico</item>
    <item>http://au.search.yahoo.com/search?ei={inputEncoding}&amp;fr=crmas&amp;p={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://aue-sayt.ff.search.yahoo.com/gossip-au-sayt?output=fxjson&amp;command={searchTerms}</item>
  </string-array>
  <string-array name="bing_pt_BR" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=pt-BR&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="bing" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>
  <string-array name="netsprint" translatable="false">
    <item>NetSprint</item>
    <item>netsprint.pl</item>
    <item>http://netsprint.pl/favicon.ico</item>
    <item>http://www.netsprint.pl/serwis/search?q={searchTerms}</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
  <string-array name="naver" translatable="false">
    <item>네이버</item>
    <item>naver.com</item>
    <item>http://search.naver.com/favicon.ico</item>
    <item>http://search.naver.com/search.naver?ie={inputEncoding}&amp;query={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://ac.search.naver.com/autocompl?m=s&amp;ie={inputEncoding}&amp;oe=utf-8&amp;q={searchTerms}</item>
  </string-array>
  <string-array name="bing_en_ZA" translatable="false">
    <item>Bing</item>
    <item>bing.com</item>
    <item>http://www.bing.com/s/wlflag.ico</item>
    <item>http://www.bing.com/search?setmkt=en-ZA&amp;q={searchTerms}</item>
    <item>UTF-8</item>
    <item>http://api.bing.com/osjson.aspx?query={searchTerms}&amp;language={language}</item>
  </string-array>

<!-- add for CMCC 139 search -->
  <string-array name="cmcc_cn" translatable="false">
    <item>139搜索</item>
    <item>s.139.com</item>
    <item>http://s.139.com/favicon.ico</item>
    <item>http://s.139.com/search.do?q={searchTerms}&amp;category=downloadable|web|browseable&amp;tid=2123,2124,2125,2126&amp;fr=portalcustom2</item>
    <item>GB2312</item>
    <item></item>
  </string-array>

  <string-array name="cmcc" translatable="false">
    <item>139 Search</item>
    <item>s.139.com</item>
    <item>http://s.139.com/favicon.ico</item>
    <item>http://s.139.com/search.do?q={searchTerms}&amp;category=downloadable|web|browseable&amp;tid=2123,2124,2125,2126&amp;fr=portalcustom2</item>
    <item>UTF-8</item>
    <item></item>
  </string-array>
<!-- end add  -->

  <!-- Custom search engines used from overlays -->
  <string-array name="custom_search_engine_1" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_2" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_3" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_4" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_5" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_6" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_7" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_8" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_9" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_10" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_11" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_12" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_13" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_14" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_15" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_16" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_17" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_18" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_19" translatable="false">
  </string-array>
  <string-array name="custom_search_engine_20" translatable="false">
  </string-array>
</resources>

donottranslate-search_engines.xml中的search_engines配置,注意每种语言values下都有一个donottranslate-search_engines  都要配置,否则切换语言会导致引擎列表不一样

donottranslate-search_engines.xml<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
  <string-array name="search_engines" translatable="false">
    <item>cmcc</item>
    <item>baidu</item>
    <item>yahoo</item>
    <item>bing</item>
  </string-array>
  <string name="default_search_engine_value">baidu</string>
</resources>

SearchEngines.getSearchEngineInfos(context)将search_engines配置的item拿到,然后去all_search_engines.xml中匹配,获取对应的SearchEngineInfo,然后显示引擎列表。

 public SearchEngineInfo(Context context, String name) throws IllegalArgumentException {
        mName = name;

        final Resources res = context.getResources();
        String packageName = R.class.getPackage().getName();
        int id_data = res.getIdentifier(name, "array", packageName);
        if(id_data == 0) {
            id_data = res.getIdentifier(name, "array", context.getPackageName());
        }
        if (id_data == 0) {
            throw new IllegalArgumentException("No resources found for " + name);
        }
        mSearchEngineData = res.getStringArray(id_data);

        if (mSearchEngineData == null) {
            throw new IllegalArgumentException("No data found for " + name);
        }
        if (mSearchEngineData.length != NUM_FIELDS) {
                throw new IllegalArgumentException(
                        name + " has invalid number of fields - " + mSearchEngineData.length);
        }
        if (TextUtils.isEmpty(mSearchEngineData[FIELD_SEARCH_URI])) {
            throw new IllegalArgumentException(name + " has an empty search URI");
        }

        // Add the current language/country information to the URIs.
        Locale locale = context.getResources().getConfiguration().locale;
        StringBuilder language = new StringBuilder(locale.getLanguage());
        if (!TextUtils.isEmpty(locale.getCountry())) {
            language.append(‘-‘);
            language.append(locale.getCountry());
        }

        String language_str = language.toString();
        mSearchEngineData[FIELD_SEARCH_URI] =
                mSearchEngineData[FIELD_SEARCH_URI].replace(PARAMETER_LANGUAGE, language_str);
        mSearchEngineData[FIELD_SUGGEST_URI] =
                mSearchEngineData[FIELD_SUGGEST_URI].replace(PARAMETER_LANGUAGE, language_str);

        // Default to UTF-8 if not specified.
        String enc = mSearchEngineData[FIELD_ENCODING];
        if (TextUtils.isEmpty(enc)) {
            enc = "UTF-8";
            mSearchEngineData[FIELD_ENCODING] = enc;
        }

        // Add the input encoding method to the URI.
        mSearchEngineData[FIELD_SEARCH_URI] =
                mSearchEngineData[FIELD_SEARCH_URI].replace(PARAMETER_INPUT_ENCODING, enc);
        mSearchEngineData[FIELD_SUGGEST_URI] =
                mSearchEngineData[FIELD_SUGGEST_URI].replace(PARAMETER_INPUT_ENCODING, enc);
    }

时间: 2024-11-08 10:01:31

Browser设置搜索引擎的相关文章

Browser设置UA值

SWE Browser中的OptionMenu是Controller通过onKeyDown监听KEYCODE_MENU来显示的 public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) { // Hardware menu key mAppMenuHandler.showAppMenu(mActivi

一起学libcef--给你的浏览器设置url

如果你是初学者,你很可能会跟我一样,遇到这样的问题,即如何给cef browser设置url,或是改变cef browser的url. 对于创建一个browser,你可能很轻松的驾驭,并再创建browser的时候,传递一个url.比如导航到"www.baidu.com".但是接下来,你想导航到"www.google.com",你会怎么做呢? 也许你会重新create一个browser,并成功导航至"www.google.com".但此时,你打开任

设置浏览器主页步骤

主页:http://www.2345.com/?kokregister 设置搜索引擎的方法: 百度---baidu.com---http://www.baidu.com/s?wd=%s 淘宝---taobao.com---http://s.taobao.com/search?q=%s 搜狗---sogou.com---http://www.sogou.com/web?query=%s 必应---cn.bing.com---http://cn.bing.com/search?q=%s 360---

关于robots.txt设置方法

通过网站访问日志我们可以看见很多蜘蛛爬行记录.搜索引擎都遵守互联网robots协议,是放置在网站根目录下robots.txt文本文件,在文件中可以设定搜索引擎蜘蛛爬行规则,以及设置搜索引擎蜘蛛Spider抓取内容规则. 通过robots.txt来进行限制,首先在网站跟目录下面建立一个robots.txt文件.下面先对robots.txt一些实例说明,然后根据网站情况进行规则设置.下面列出一些设置规则供大家参考. I . 禁止所有搜索引擎访问网站的任何部分 User-agent: * Disall

Linux下安装MySQL管理工具MySQL Administrator和MySQL Query Browser(转载)

文章来源:http://blog.csdn.net/sunrier/article/details/7572299 Linux下MySQL Administrator和MySQL Query Browser的安装 下面为本人第一次安装过程(Red Hat Enterprise Linux 5)先在官网下载http://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-gui-tools-5.0r12-rhel4-i386.tar.gz/from/pi

ceph rgw 对象存储 对象 生命周期 设置 -- lifecycle

1.简介 1.1 介绍     对于 存储 来说,容量 当然是 越大越好了,最好 可以 无限 写入(哈哈,哪有 那么 好的 事):但是 我们 可以 删除 老旧 无用的数据,不过 总不能 时时刻刻 的手动 删除 数据吧:我们 可以 根据 一定的规则 删除 老旧的数据,此时 就可以 设置 对象 生命周期规则,制定 数据 删除 规则,对于 客户来说,集群 好像 就可以 无限量 写入了(哈哈哈,所以 后端 才是 真实的,但是 删除 数据 有风险,谨慎操作哦!!!)     1.2 前提 条件     你

firfox与about:config

¤什么是about:config¤about:config是Firefox的设置页面,Firefox提供了不少高级设置选项在这里以便让你可以更加详细地控制Firefox的运行方式.官方不推荐用户手工修改about:config的设置.所以,如果你对于你想修改的内容不是非常确定的话,请不要去改变它.)打开Firefox中about:config设置的方法是在Firefox地址栏输入about:config,然后回车.这份列表包括了尽可能多的 Mozilla参数.虽然它并不完整,但它可以说是目前互联

python前端HTML和CSS入门

前端阶段课程介绍1 ~ 4 : HTML及CSS5 ~ 6 : JavaScript 7 ~ 10 : jQuery 00-知识点预习1.HTML基本结构2.HTML的常用标签3.HTML布局入门4.CSS概述5.CSS书写方式6.CSS常用选择器7.CSS常用属性 01-什么是HTML?HTML 是用来描述网页的一种语言. HTML 指的是超文本标记语言: HyperText Markup LanguageHTML 不是一种编程语言,而是一种标记语言 标记语言是一套标记标签 (markup t

使用RStudio调试基础学习(一)

本文知识点: 使用Rstudio调试的基础知识 点击行号的左侧,即可设置断点(或者按下Shift+F9),如果没有出现,反而出现下图的警告: 那么只是因为我的坏习惯——写一段脚本测试的时候都是新建,但不save到本地,不喜欢保存,写的差不多了才开始取名字保存.... 写一个for循环测试下: test <-0 for(i in1:9){ j <- i+2 test[i+1]<- test[i]+3 k <- i } 将environment窗口下,选择grid(如果选来是list的