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


Java ShortcutQuery.setActivity方法代码示例

本文整理汇总了Java中android.content.pm.LauncherApps.ShortcutQuery.setActivity方法的典型用法代码示例。如果您正苦于以下问题:Java ShortcutQuery.setActivity方法的具体用法?Java ShortcutQuery.setActivity怎么用?Java ShortcutQuery.setActivity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.pm.LauncherApps.ShortcutQuery的用法示例。


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

示例1: query

import android.content.pm.LauncherApps.ShortcutQuery; //导入方法依赖的package包/类
@Override
protected List<ShortcutInfoCompat> query(int flags, String packageName, ComponentName componentName, List<String> shortcutIds, UserHandle userHandle) {
    List<ShortcutInfo> shortcuts = null;
    ShortcutQuery shortcutQuery = new ShortcutQuery();
    shortcutQuery.setQueryFlags(flags);
    if (packageName != null) {
        shortcutQuery.setPackage(packageName);
        shortcutQuery.setActivity(componentName);
        shortcutQuery.setShortcutIds(shortcutIds);
    }
    try {
        shortcuts = mLauncherApps.getShortcuts(shortcutQuery, userHandle);
        mWasLastCallSuccess = true;
    } catch (Throwable e) {
        Log.e("DeepShortcutManager", "Failed to query for shortcuts", e);
        mWasLastCallSuccess = false;
    }
    if (shortcuts == null) {
        return Collections.emptyList();
    }
    List<ShortcutInfoCompat> shortcutList = new ArrayList<>(shortcuts.size());
    for (ShortcutInfo shortcutInfoCompat : shortcuts) {
        shortcutList.add(new ShortcutInfoCompat(shortcutInfoCompat));
    }
    return shortcutList;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:27,代码来源:DeepShortcutManagerN.java

示例2: query

import android.content.pm.LauncherApps.ShortcutQuery; //导入方法依赖的package包/类
/**
 * Query the system server for all the shortcuts matching the given parameters.
 * If packageName == null, we query for all shortcuts with the passed flags, regardless of app.
 *
 * TODO: Use the cache to optimize this so we don't make an RPC every time.
 */
@TargetApi(25)
private List<ShortcutInfoCompat> query(int flags, String packageName,
        ComponentName activity, List<String> shortcutIds, UserHandle user) {
    if (AndroidVersion.isAtLeastNougatMR1) {
        ShortcutQuery q = new ShortcutQuery();
        q.setQueryFlags(flags);
        if (packageName != null) {
            q.setPackage(packageName);
            q.setActivity(activity);
            q.setShortcutIds(shortcutIds);
        }
        List<ShortcutInfo> shortcutInfos = null;
        try {
            shortcutInfos = mLauncherApps.getShortcuts(q, user);
            mWasLastCallSuccess = true;
        } catch (SecurityException|IllegalStateException e) {
            e.printStackTrace();
            mWasLastCallSuccess = false;
        }
        if (shortcutInfos == null) {
            return Collections.EMPTY_LIST;
        }
        List<ShortcutInfoCompat> shortcutInfoCompats = new ArrayList<>(shortcutInfos.size());
        for (ShortcutInfo shortcutInfo : shortcutInfos) {
            shortcutInfoCompats.add(new ShortcutInfoCompat(shortcutInfo));
        }
        return shortcutInfoCompats;
    } else {
        return Collections.EMPTY_LIST;
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:38,代码来源:DeepShortcutManager.java

示例3: query

import android.content.pm.LauncherApps.ShortcutQuery; //导入方法依赖的package包/类
/**
 * Query the system server for all the shortcuts matching the given parameters.
 * If packageName == null, we query for all shortcuts with the passed flags, regardless of app.
 *
 * TODO: Use the cache to optimize this so we don't make an RPC every time.
 */
@TargetApi(25)
private List<ShortcutInfoCompat> query(int flags, String packageName,
        ComponentName activity, List<String> shortcutIds, UserHandleCompat user) {
    if (Utilities.isNycMR1OrAbove()) {
        ShortcutQuery q = new ShortcutQuery();
        q.setQueryFlags(flags);
        if (packageName != null) {
            q.setPackage(packageName);
            q.setActivity(activity);
            q.setShortcutIds(shortcutIds);
        }
        List<ShortcutInfo> shortcutInfos = null;
        try {
            shortcutInfos = mLauncherApps.getShortcuts(q, user.getUser());
            mWasLastCallSuccess = true;
        } catch (SecurityException|IllegalStateException e) {
            Log.e(TAG, "Failed to query for shortcuts", e);
            mWasLastCallSuccess = false;
        }
        if (shortcutInfos == null) {
            return Collections.EMPTY_LIST;
        }
        List<ShortcutInfoCompat> shortcutInfoCompats = new ArrayList<>(shortcutInfos.size());
        for (ShortcutInfo shortcutInfo : shortcutInfos) {
            shortcutInfoCompats.add(new ShortcutInfoCompat(shortcutInfo));
        }
        return shortcutInfoCompats;
    } else {
        return Collections.EMPTY_LIST;
    }
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:38,代码来源:DeepShortcutManager.java


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