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


Java DashClockExtension类代码示例

本文整理汇总了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);
}
 
开发者ID:mridang,项目名称:dashbar,代码行数:26,代码来源:PeriodicExtensionRefreshReceiver.java

示例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;
}
 
开发者ID:mridang,项目名称:dashbar,代码行数:21,代码来源:DashClockService.java

示例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);
    }
}
 
开发者ID:mridang,项目名称:dashbar,代码行数:26,代码来源:DashClockService.java

示例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);
}
 
开发者ID:mridang,项目名称:dashbar,代码行数:22,代码来源:ConfigurationActivity.java

示例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();
    }
}
 
开发者ID:tasomaniac,项目名称:hackdash,代码行数:23,代码来源:SettingsActivity.java

示例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;
}
 
开发者ID:mridang,项目名称:dashbar,代码行数:35,代码来源:DashClockHost.java

示例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));
}
 
开发者ID:mridang,项目名称:dashbar,代码行数:11,代码来源:PeriodicExtensionRefreshReceiver.java

示例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;
}
 
开发者ID:mridang,项目名称:dashbar,代码行数:34,代码来源:ExtensionManager.java

示例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();
}
 
开发者ID:mridang,项目名称:dashbar,代码行数:13,代码来源:ExtensionSettingActivityProxy.java

示例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);
        }
    }
}
 
开发者ID:romannurik,项目名称:dashclock,代码行数:10,代码来源:ExtensionHost.java

示例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()));

}
 
开发者ID:romannurik,项目名称:dashclock,代码行数:15,代码来源:WeatherRetryReceiver.java

示例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;
}
 
开发者ID:tasomaniac,项目名称:hackdash,代码行数:8,代码来源:SettingsFragment.java

示例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);
    }
}
 
开发者ID:tasomaniac,项目名称:hackdash,代码行数:9,代码来源:SettingsFragment.java

示例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));
        }
    }
}
 
开发者ID:JesusM,项目名称:DashClock,代码行数:9,代码来源:ExtensionHost.java

示例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;
}
 
开发者ID:JesusM,项目名称:DashClock,代码行数:31,代码来源:ExtensionManager.java


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