本文整理汇总了Java中com.google.android.apps.dashclock.api.DashClockExtension类的典型用法代码示例。如果您正苦于以下问题:Java DashClockExtension类的具体用法?Java DashClockExtension怎么用?Java DashClockExtension使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DashClockExtension类属于com.google.android.apps.dashclock.api包,在下文中一共展示了DashClockExtension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateExtensionsAndEnsurePeriodicRefresh
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
/**
* Sets the refresh schedule if one isn't set already.
*/
public static void updateExtensionsAndEnsurePeriodicRefresh(final Context context) {
LOGD(TAG, "updateExtensionsAndEnsurePeriodicRefresh");
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// Update all extensions now.
context.startService(getUpdateAllExtensionsIntent(context,
DashClockExtension.UPDATE_REASON_MANUAL));
// Schedule an alarm for every 30 minutes; it will not wake up the device;
// it will be handled only once the device is awake. The first time that this
// alarm can go off is in 15 minutes, and the latest time it will go off is
// 45 minutes from now.
PendingIntent pi = PendingIntent.getBroadcast(context, 0,
new Intent(context, PeriodicExtensionRefreshReceiver.class)
.setAction(ACTION_PERIODIC_ALARM),
PendingIntent.FLAG_UPDATE_CURRENT);
am.cancel(pi);
am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
SystemClock.elapsedRealtime() + 15 * MINUTES_MILLIS,
AlarmManager.INTERVAL_HALF_HOUR,
pi);
}
示例2: onStartCommand
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
LOGD(TAG, "onStartCommand: " + (intent != null ? intent.toString() : "no intent"));
enforceCallingPermission(DashClockExtension.PERMISSION_READ_EXTENSION_DATA);
if (intent != null) {
String action = intent.getAction();
if (ACTION_UPDATE_WIDGETS.equals(action)) {
handleUpdateWidgets(intent);
} else if (ACTION_UPDATE_EXTENSIONS.equals(action)) {
handleUpdateExtensions(intent);
}
// If started by a wakeful broadcast receiver, release the wake lock it acquired.
WakefulBroadcastReceiver.completeWakefulIntent(intent);
}
return START_STICKY;
}
示例3: internalRequestUpdateData
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
private void internalRequestUpdateData(final IDataConsumerHostCallback cb,
List<ComponentName> extensions) {
// Recover the updatable extensions for this caller
List<ComponentName> updatableExtensions = new ArrayList<>();
List<ComponentName> registeredExtensions =
mRegisteredCallbacks.get(cb.asBinder()).mExtensions;
if (extensions == null) {
updatableExtensions.addAll(registeredExtensions);
} else {
for (ComponentName extension : extensions) {
if (registeredExtensions.contains(extension)) {
updatableExtensions.add(extension);
}
}
}
// Request an update of all the extensions in the list
final LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
for (ComponentName updatableExtension: updatableExtensions) {
Intent intent = new Intent(ACTION_EXTENSION_UPDATE_REQUESTED);
intent.putExtra(EXTRA_COMPONENT_NAME, updatableExtension.flattenToString());
intent.putExtra(EXTRA_UPDATE_REASON, DashClockExtension.UPDATE_REASON_MANUAL);
lbm.sendBroadcast(intent);
}
}
示例4: onStop
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
@Override
protected void onStop() {
super.onStop();
// Update extensions (settings may have changed)
// TODO: update only those extensions whose settings have changed
Intent updateExtensionsIntent = new Intent(this, DashClockService.class);
updateExtensionsIntent.setAction(DashClockService.ACTION_UPDATE_EXTENSIONS);
updateExtensionsIntent.putExtra(DashClockService.EXTRA_UPDATE_REASON,
DashClockExtension.UPDATE_REASON_SETTINGS_CHANGED);
startService(updateExtensionsIntent);
// Update all widgets, including a new one if it was just added
// We can't only update the new one because settings affecting all widgets may have
// been changed.
LOGD(TAG, "Updating all widgets");
Intent widgetUpdateIntent = new Intent(this, DashClockService.class);
widgetUpdateIntent.setAction(DashClockService.ACTION_UPDATE_WIDGETS);
startService(widgetUpdateIntent);
}
示例5: onCreate
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
boolean fromDashClock = getIntent().getBooleanExtra(DashClockExtension.EXTRA_FROM_DASHCLOCK_SETTINGS, false);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationIcon(R.drawable.ic_action_done);
toolbar.setNavigationContentDescription(R.string.done);
setSupportActionBar(toolbar);
CollapsingToolbarLayout collapsingToolbar =
(CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapsingToolbar.setTitle(getString(R.string.settings_label));
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.fragment_container,
SettingsFragment.newInstance(fromDashClock))
.commit();
}
}
示例6: getOtherAppsWithReadDataExtensionsPermission
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
/**
* Return a list of packages that implement the {@link
* DashClockExtension#PERMISSION_READ_EXTENSION_DATA} permission and aren't DashClock
*/
public static List<String> getOtherAppsWithReadDataExtensionsPermission(Context context) {
List<String> installedApps = new ArrayList<>();
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
// There is no problem with the PERMISSION_READ_EXTENSION_DATA if
// the api supports multiple apps defining the same permission (< Lollipop)
return installedApps;
}
PackageManager pm = context.getPackageManager();
List<ApplicationInfo> apps = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo ai : apps) {
try {
PackageInfo pi = pm.getPackageInfo(ai.packageName, PackageManager.GET_PERMISSIONS);
PermissionInfo[] perms = pi.permissions;
if (perms != null) {
for (PermissionInfo perm : perms) {
if (perm.name.equals(DashClockExtension.PERMISSION_READ_EXTENSION_DATA)) {
if (!ai.packageName.equals(MULTIPLEXER_HOST_SERVICE.getPackageName())) {
installedApps.add(ai.packageName);
break;
}
}
}
}
} catch (NameNotFoundException ex) {
// Ignore
}
}
return installedApps;
}
示例7: onReceive
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (intent == null || !ACTION_PERIODIC_ALARM.equals(intent.getAction())) {
return;
}
// Periodic alarm has triggered. Update all extensions.
startWakefulService(context,
getUpdateAllExtensionsIntent(context, DashClockExtension.UPDATE_REASON_PERIODIC));
}
示例8: getAvailableExtensions
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
/**
* Returns a listing of all available (installed) extensions, including those that aren't
* world-readable.
*/
public List<ExtensionListing> getAvailableExtensions() {
List<ExtensionListing> availableExtensions = new ArrayList<>();
PackageManager pm = mApplicationContext.getPackageManager();
List<ResolveInfo> resolveInfos = pm.queryIntentServices(
new Intent(DashClockExtension.ACTION_EXTENSION), PackageManager.GET_META_DATA);
for (ResolveInfo resolveInfo : resolveInfos) {
ExtensionListing info = new ExtensionListing();
info.componentName(new ComponentName(resolveInfo.serviceInfo.packageName,
resolveInfo.serviceInfo.name));
info.title(resolveInfo.loadLabel(pm).toString());
Bundle metaData = resolveInfo.serviceInfo.metaData;
if (metaData != null) {
info.compatible(ExtensionHost.supportsProtocolVersion(
metaData.getInt("protocolVersion")));
info.worldReadable(metaData.getBoolean("worldReadable", false));
info.description(metaData.getString("description"));
String settingsActivity = metaData.getString("settingsActivity");
if (!TextUtils.isEmpty(settingsActivity)) {
info.settingsActivity(ComponentName.unflattenFromString(
resolveInfo.serviceInfo.packageName + "/" + settingsActivity));
}
}
info.icon(resolveInfo.getIconResource());
availableExtensions.add(info);
}
return availableExtensions;
}
示例9: onActivityResult
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RESULT_EXTENSION_SETTINGS) {
final LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
Intent intent = new Intent(DashClockService.ACTION_EXTENSION_UPDATE_REQUESTED);
intent.putExtra(DashClockService.EXTRA_COMPONENT_NAME, mExtension);
intent.putExtra(DashClockService.EXTRA_UPDATE_REASON,
DashClockExtension.UPDATE_REASON_SETTINGS_CHANGED);
lbm.sendBroadcast(intent);
}
finish();
}
示例10: onReceive
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
synchronized (mExtensionsToUpdateWhenScreenOn) {
for (ComponentName cn : mExtensionsToUpdateWhenScreenOn) {
execute(cn, UPDATE_OPERATIONS.get(DashClockExtension.UPDATE_REASON_SCREEN_ON),
0, null);
}
}
}
示例11: onReceive
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
// Update weather
// TODO: there should be a way for an extension to request an update through the API
// See issue 292.
context.startService(new Intent(context, DashClockService.class)
.setAction(DashClockService.ACTION_UPDATE_EXTENSIONS)
.putExtra(DashClockService.EXTRA_UPDATE_REASON,
DashClockExtension.UPDATE_REASON_UNKNOWN) // TODO: UPDATE_REASON_RETRY
.putExtra(DashClockService.EXTRA_COMPONENT_NAME,
new ComponentName(context, WeatherExtension.class)
.flattenToShortString()));
}
示例12: newInstance
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
public static SettingsFragment newInstance(boolean fromDashClock) {
SettingsFragment fragment = new SettingsFragment();
Bundle args = new Bundle();
args.putBoolean(DashClockExtension.EXTRA_FROM_DASHCLOCK_SETTINGS, fromDashClock);
fragment.setArguments(args);
return fragment;
}
示例13: removeDashClockPrefIfNotNecessary
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
private void removeDashClockPrefIfNotNecessary() {
//Remove dashclock pref if the user is coming from DashClock app.
PreferenceCategory integrations = (PreferenceCategory) findPreference(R.string.pref_key_integrations);
boolean fromDashClock = getArguments().getBoolean(DashClockExtension.EXTRA_FROM_DASHCLOCK_SETTINGS, false);
if (fromDashClock) {
integrations.removePreference(dashclockPref);
}
}
示例14: onReceive
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
synchronized (mExtensionsToUpdateWhenScreenOn) {
for (ComponentName cn : mExtensionsToUpdateWhenScreenOn) {
execute(cn, UPDATE_OPERATIONS.get(DashClockExtension.UPDATE_REASON_SCREEN_ON));
}
}
}
示例15: getAvailableExtensions
import com.google.android.apps.dashclock.api.DashClockExtension; //导入依赖的package包/类
/**
* Returns a listing of all available (installed) extensions.
*/
public List<ExtensionListing> getAvailableExtensions() {
List<ExtensionListing> availableExtensions = new ArrayList<ExtensionListing>();
PackageManager pm = mApplicationContext.getPackageManager();
List<ResolveInfo> resolveInfos = pm.queryIntentServices(
new Intent(DashClockExtension.ACTION_EXTENSION), PackageManager.GET_META_DATA);
for (ResolveInfo resolveInfo : resolveInfos) {
ExtensionListing listing = new ExtensionListing();
listing.componentName = new ComponentName(resolveInfo.serviceInfo.packageName,
resolveInfo.serviceInfo.name);
listing.title = resolveInfo.loadLabel(pm).toString();
Bundle metaData = resolveInfo.serviceInfo.metaData;
if (metaData != null) {
listing.protocolVersion = metaData.getInt("protocolVersion");
listing.description = metaData.getString("description");
String settingsActivity = metaData.getString("settingsActivity");
if (!TextUtils.isEmpty(settingsActivity)) {
listing.settingsActivity = ComponentName.unflattenFromString(
resolveInfo.serviceInfo.packageName + "/" + settingsActivity);
}
}
listing.icon = resolveInfo.loadIcon(pm);
availableExtensions.add(listing);
}
return availableExtensions;
}