当前位置: 首页>>代码示例>>Java>>正文


Java AppChooserPreference类代码示例

本文整理汇总了Java中com.google.android.apps.dashclock.configuration.AppChooserPreference的典型用法代码示例。如果您正苦于以下问题:Java AppChooserPreference类的具体用法?Java AppChooserPreference怎么用?Java AppChooserPreference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AppChooserPreference类属于com.google.android.apps.dashclock.configuration包,在下文中一共展示了AppChooserPreference类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onUpdateData

import com.google.android.apps.dashclock.configuration.AppChooserPreference; //导入依赖的package包/类
@Override
protected void onUpdateData(int reason) {
    String nextAlarm = Settings.System.getString(getContentResolver(),
            Settings.System.NEXT_ALARM_FORMATTED);
    if (!TextUtils.isEmpty(nextAlarm)) {
        Matcher m = sDigitPattern.matcher(nextAlarm);
        if (m.find() && m.start() > 0) {
            nextAlarm = nextAlarm.substring(0, m.start()) + "\n"
                    + nextAlarm.substring(m.start() + 1); // +1 to skip whitespace
        }
    }

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    Intent alarmIntent = AppChooserPreference.getIntentValue(
            sp.getString(PREF_ALARM_SHORTCUT, null), null);
    if (alarmIntent == null) {
        alarmIntent = Utils.getDefaultAlarmsIntent(this);
    }

    publishUpdate(new ExtensionData()
            .visible(!TextUtils.isEmpty(nextAlarm))
            .icon(R.drawable.ic_extension_next_alarm)
            .status(nextAlarm)
            .clickIntent(alarmIntent));
}
 
开发者ID:romannurik,项目名称:dashclock,代码行数:26,代码来源:NextAlarmExtension.java

示例2: onUpdateData

import com.google.android.apps.dashclock.configuration.AppChooserPreference; //导入依赖的package包/类
@Override
protected void onUpdateData(int reason) {
    if (mServiceThreadHandler == null) {
        // Get handle to background thread
        mServiceThreadHandler = new Handler(Looper.myLooper());
    }

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    sWeatherUnits = sp.getString(PREF_WEATHER_UNITS, sWeatherUnits);
    sWeatherIntent = AppChooserPreference.getIntentValue(
            sp.getString(PREF_WEATHER_SHORTCUT, null), DEFAULT_WEATHER_INTENT);

    setWeatherUnits(sWeatherUnits);

    long lastUpdateElapsedMillis = sp.getLong(STATE_WEATHER_LAST_UPDATE_ELAPSED_MILLIS,
            -UPDATE_THROTTLE_MILLIS);
    long nowElapsedMillis = SystemClock.elapsedRealtime();
    if (reason != UPDATE_REASON_INITIAL && reason != UPDATE_REASON_MANUAL &&
            nowElapsedMillis < lastUpdateElapsedMillis + UPDATE_THROTTLE_MILLIS) {
        LOGD(TAG, "Throttling weather update attempt.");
        return;
    }

    LOGD(TAG, "Attempting weather update; reason=" + reason);

    NetworkInfo ni = ((ConnectivityManager) getSystemService(
            Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
    if (ni == null || !ni.isConnected()) {
        LOGD(TAG, "No network connection; not attempting to update weather.");
        return;
    }

    String manualLocationWoeid = WeatherLocationPreference.getWoeidFromValue(
            sp.getString(PREF_WEATHER_LOCATION, null));
    if (!TextUtils.isEmpty(manualLocationWoeid)) {
        // WOEIDs
        // Honolulu = 2423945
        // Paris = 615702
        // London = 44418
        // New York = 2459115
        // San Francisco = 2487956
        LocationInfo locationInfo = new LocationInfo();
        locationInfo.woeids = Arrays.asList(manualLocationWoeid);
        tryPublishWeatherUpdateFromLocationInfo(locationInfo);
        return;
    }

    // Get the user's location, then get the weather for that location.
    tryGooglePlayServicesGetLocationAndPublishWeatherUpdate(new Runnable() {
        @Override
        public void run() {
            // If there was an error with Play Services, try LocationManager
            tryLocationManagerGetLocationAndPublishWeatherUpdate();
        }
    });
}
 
开发者ID:romannurik,项目名称:dashclock,代码行数:57,代码来源:WeatherExtension.java

示例3: onCreate

import com.google.android.apps.dashclock.configuration.AppChooserPreference; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	preferences = PreferenceManager.getDefaultSharedPreferences(this);
	editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
	String packageName = getIntent().getStringExtra("packageName");
	String extNumber = getIntent().getStringExtra("extNumber");
	Intent clickIntent = new Intent();
	try {
		int count = getContentResolver().delete(
				NotificationProvider.CONTENT_URI,
				NotifSQLiteHelper.COL_PNAME + " = ? AND "
						+ NotifSQLiteHelper.COL_NOTIF_ID + " = ? ",
				new String[] { packageName,
						Integer.toString(1) });
		Log.v("ClickIntentActivity", "Deleted: " + Integer.toString(count));
		//restore from backup fr always_show extensions
		if (preferences.getBoolean("always_show"+ extNumber, false)){
			if (!TextUtils.isEmpty(preferences.getString("iconExt_default_"+extNumber, "")))
				editor.putString("iconExt"+extNumber, preferences.getString("iconExt_default_"+extNumber, ""));
			else{
				editor.remove("iconExt"+extNumber);
				editor.putString("icon_preference"+extNumber, preferences.getString("icon_preference_default_"+extNumber, ""));
			}
				
			editor.commit();
		}
		try {
			clickIntent = getPackageManager().getLaunchIntentForPackage(packageName)
					.addCategory(Intent.CATEGORY_DEFAULT);
		} catch (NullPointerException npe) {
			clickIntent.setAction(Intent.ACTION_MAIN);
			clickIntent.addCategory(Intent.CATEGORY_HOME);
			clickIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		} finally {
			clickIntent = AppChooserPreference.getIntentValue(
					preferences.getString("click_intent" + extNumber, ""),
					clickIntent);
		}
		startActivity(clickIntent);
		finish();
	} catch (Exception e) {

		Log.e("ClickIntentActivity", e.getClass().getName());
		e.printStackTrace();
	}
	
}
 
开发者ID:umanx,项目名称:DashNotifier,代码行数:49,代码来源:ClickIntentActivity.java


注:本文中的com.google.android.apps.dashclock.configuration.AppChooserPreference类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。