本文整理汇总了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));
}
示例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();
}
});
}
示例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();
}
}