コード例 #1
0
  @Override
  public void onReceive(Context context, Intent intent) {
    SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = p.edit();
    if (null == intent.getExtras()) {
      return;
    }

    String searchEngineName = intent.getExtras().getString(BrowserSettings.PREF_SEARCH_ENGINE);
    String searchEngineFavicon = "";
    ISearchEngineManager searchEngineManager =
        (ISearchEngineManager) context.getSystemService(Context.SEARCH_ENGINE_SERVICE);
    SearchEngineInfo searchEngineInfo = searchEngineManager.getSearchEngineByName(searchEngineName);
    if (searchEngineInfo != null) {
      searchEngineFavicon = searchEngineInfo.getFaviconUri();
    }
    editor.putString(BrowserSettings.PREF_SEARCH_ENGINE, searchEngineName);
    editor.putString(BrowserSettings.PREF_SEARCH_ENGINE_FAVICON, searchEngineFavicon);
    editor.commit();
    Xlog.d(
        XLOGTAG,
        "ChangeSearchEngineReceiver"
            + BrowserSettings.PREF_SEARCH_ENGINE
            + "---"
            + intent.getExtras().getString(BrowserSettings.PREF_SEARCH_ENGINE));
  }