• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java LauncherActivityInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getApplicationInfo

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
@Override
public ApplicationInfo getApplicationInfo(String packageName, int flags, UserHandle user) {
    final boolean isPrimaryUser = Process.myUserHandle().equals(user);
    if (!isPrimaryUser && (flags == 0)) {
        // We are looking for an installed app on a secondary profile. Prior to O, the only
        // entry point for work profiles is through the LauncherActivity.
        List<LauncherActivityInfo> activityList =
                mLauncherApps.getActivityList(packageName, user);
        return activityList.size() > 0 ? activityList.get(0).getApplicationInfo() : null;
    }
    try {
        ApplicationInfo info =
                mContext.getPackageManager().getApplicationInfo(packageName, flags);
        // There is no way to check if the app is installed for managed profile. But for
        // primary profile, we can still have this check.
        if (isPrimaryUser && ((info.flags & ApplicationInfo.FLAG_INSTALLED) == 0)
                || !info.enabled) {
            return null;
        }
        return info;
    } catch (PackageManager.NameNotFoundException e) {
        // Package not found
        return null;
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:26,代码来源:LauncherAppsCompatVL.java


示例2: startConfigActivity

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
@Override
public boolean startConfigActivity(Activity activity, int requestCode) {
    if (getUser().equals(Process.myUserHandle())) {
        return super.startConfigActivity(activity, requestCode);
    }
    try {
        Method m = LauncherApps.class.getDeclaredMethod(
                "getShortcutConfigActivityIntent", LauncherActivityInfo.class);
        IntentSender is = (IntentSender) m.invoke(
                activity.getSystemService(LauncherApps.class), mInfo);
        activity.startIntentSenderForResult(is, requestCode, null, 0, 0, 0);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:18,代码来源:ShortcutConfigActivityInfo.java


示例3: onPackageAdded

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
@Override
public void onPackageAdded(String packageName, UserHandle user) {
    String prefKey = INSTALLED_PACKAGES_PREFIX + mUserManager.getSerialNumberForUser(user);
    HashSet<String> packageSet = new HashSet<>();
    final boolean userAppsExisted = getUserApps(packageSet, prefKey);
    if (!packageSet.contains(packageName)) {
        List<LauncherActivityInfo> activities =
                mLauncherApps.getActivityList(packageName, user);
        if (!activities.isEmpty()) {
            LauncherActivityInfo activityInfo = activities.get(0);

            packageSet.add(packageName);
            mPrefs.edit().putStringSet(prefKey, packageSet).apply();
            onLauncherAppsAdded(Arrays.asList(
                    new LauncherActivityInstallInfo(activityInfo, System.currentTimeMillis())),
                    user, userAppsExisted);
        }
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:20,代码来源:CachedPackageTracker.java


示例4: updateIconsForPkg

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
/**
 * Updates the entries related to the given package in memory and persistent DB.
 */
public synchronized void updateIconsForPkg(String packageName, UserHandle user) {
    removeIconsForPkg(packageName, user);
    try {
        int uninstalled = android.os.Build.VERSION.SDK_INT >= 24 ? PackageManager.MATCH_UNINSTALLED_PACKAGES : PackageManager.GET_UNINSTALLED_PACKAGES;

        PackageInfo info = mPackageManager.getPackageInfo(packageName,
                uninstalled);
        long userSerial = mUserManager.getSerialNumberForUser(user);
        for (LauncherActivityInfo app : mLauncherApps.getActivityList(packageName, user)) {
            addIconToDBAndMemCache(app, info, userSerial, false /*replace existing*/);
        }
    } catch (NameNotFoundException e) {
        e.printStackTrace();
        return;
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:20,代码来源:IconCache.java


示例5: updateDbIcons

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
public void updateDbIcons(Set<String> ignorePackagesForMainUser) {
    // Remove all active icon update tasks.
    mWorkerHandler.removeCallbacksAndMessages(ICON_UPDATE_TOKEN);

    mIconProvider.updateSystemStateString();
    for (UserHandle user : mUserManager.getUserProfiles()) {
        // Query for the set of apps
        final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
        // Fail if we don't have any apps
        // TODO: Fix this. Only fail for the current user.
        if (apps == null || apps.isEmpty()) {
            return;
        }

        // Update icon cache. This happens in segments and {@link #onPackageIconsUpdated}
        // is called by the icon cache when the job is complete.
        updateDBIcons(user, apps, Process.myUserHandle().equals(user)
                ? ignorePackagesForMainUser : Collections.<String>emptySet());
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:21,代码来源:IconCache.java


示例6: addIconToDBAndMemCache

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
/**
 * Adds an entry into the DB and the in-memory cache.
 * @param replaceExisting if true, it will recreate the bitmap even if it already exists in
 *                        the memory. This is useful then the previous bitmap was created using
 *                        old data.
 */
@Thunk private synchronized void addIconToDBAndMemCache(LauncherActivityInfo app,
        PackageInfo info, long userSerial, boolean replaceExisting) {
    final ComponentKey key = new ComponentKey(app.getComponentName(), app.getUser());
    CacheEntry entry = null;
    if (!replaceExisting) {
        entry = mCache.get(key);
        // We can't reuse the entry if the high-res icon is not present.
        if (entry == null || entry.isLowResIcon || entry.icon == null) {
            entry = null;
        }
    }
    if (entry == null) {
        entry = new CacheEntry();
        entry.icon = LauncherIcons.createBadgedIconBitmap(getFullResIcon(app), app.getUser(),
                mContext,  app.getApplicationInfo().targetSdkVersion);
    }
    entry.title = app.getLabel();
    entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, app.getUser());
    mCache.put(key, entry);

    Bitmap lowResIcon = generateLowResIcon(entry.icon, mActivityBgColor);
    ContentValues values = newContentValues(entry.icon, lowResIcon, entry.title.toString(),
            app.getApplicationInfo().packageName);
    addIconToDB(values, app.getComponentName(), info, userSerial);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:32,代码来源:IconCache.java


示例7: convertToLauncherActivityIfPossible

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
/**
 * Tries to create a new PendingInstallShortcutInfo which represents the same target,
 * but is an app target and not a shortcut.
 * @return the newly created info or the original one.
 */
private static PendingInstallShortcutInfo convertToLauncherActivityIfPossible(
        PendingInstallShortcutInfo original) {
    if (original.isLauncherActivity()) {
        // Already an activity target
        return original;
    }
    if (!Utilities.isLauncherAppTarget(original.launchIntent)) {
        return original;
    }

    LauncherActivityInfo info = LauncherAppsCompat.getInstance(original.mContext)
            .resolveActivity(original.launchIntent, original.user);
    if (info == null) {
        return original;
    }
    // Ignore any conflicts in the label name, as that can change based on locale.
    return new PendingInstallShortcutInfo(info, original.mContext);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:24,代码来源:InstallShortcutReceiver.java


示例8: getView

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
    ViewHolder holder = new ViewHolder();
    if(convertView == null) {
        convertView = mInflater.inflate(R.layout.app_list_item,null, false);
        holder.icon = (ImageView)convertView.findViewById(R.id.icon);
        holder.lable = (TextView)convertView.findViewById(R.id.label);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    LauncherActivityInfo appInfo = mData.get(position);
    holder.icon.setImageDrawable(appInfo.getIcon(0));
    holder.lable.setText(appInfo.getLabel());
    return convertView;
}
 
开发者ID:cumtsmart,项目名称:MostTool,代码行数:17,代码来源:AppListActivity.java


示例9: getCustomShortcutActivityList

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
@Override
public List<ShortcutConfigActivityInfo> getCustomShortcutActivityList(
        @Nullable PackageUserKey packageUser) {
    List<ShortcutConfigActivityInfo> result = new ArrayList<>();
    UserHandle myUser = Process.myUserHandle();

    try {
        Method m = LauncherApps.class.getDeclaredMethod("getShortcutConfigActivityList",
                String.class, UserHandle.class);
        final List<UserHandle> users;
        final String packageName;
        if (packageUser == null) {
            users = UserManagerCompat.getInstance(mContext).getUserProfiles();
            packageName = null;
        } else {
            users = new ArrayList<>(1);
            users.add(packageUser.mUser);
            packageName = packageUser.mPackageName;
        }
        for (UserHandle user : users) {
            boolean ignoreTargetSdk = myUser.equals(user);
            List<LauncherActivityInfo> activities =
                    (List<LauncherActivityInfo>) m.invoke(mLauncherApps, packageName, user);
            for (LauncherActivityInfo activityInfo : activities) {
                if (ignoreTargetSdk || activityInfo.getApplicationInfo().targetSdkVersion >=
                        Build.VERSION_CODES.O) {
                    result.add(new ShortcutConfigActivityInfoVO(activityInfo));
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return result;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:37,代码来源:LauncherAppsCompatVO.java


示例10: getAppShortcutInfo

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
/**
 * Make an ShortcutInfo object for a shortcut that is an application.
 */
public ShortcutInfo getAppShortcutInfo(
        Intent intent, boolean allowMissingTarget, boolean useLowResIcon) {
    if (user == null) {
        return null;
    }

    ComponentName componentName = intent.getComponent();
    if (componentName == null) {
        return null;
    }

    Intent newIntent = new Intent(Intent.ACTION_MAIN, null);
    newIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    newIntent.setComponent(componentName);
    LauncherActivityInfo lai = LauncherAppsCompat.getInstance(mContext)
            .resolveActivity(newIntent, user);
    if ((lai == null) && !allowMissingTarget) {
        return null;
    }

    final ShortcutInfo info = new ShortcutInfo();
    info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
    info.user = user;
    info.intent = newIntent;

    mIconCache.getTitleAndIcon(info, lai, useLowResIcon);
    if (mIconCache.isDefaultIcon(info.iconBitmap, user)) {
        Bitmap icon = loadIcon(info);
        info.iconBitmap = icon != null ? icon : info.iconBitmap;
    }

    if (lai != null && PackageManagerHelper.isAppSuspended(lai.getApplicationInfo())) {
        info.isDisabled = ShortcutInfo.FLAG_DISABLED_SUSPENDED;
    }

    // from the db
    if (TextUtils.isEmpty(info.title)) {
        info.title = getTitle();
    }

    // fall back to the class name of the activity
    if (info.title == null) {
        info.title = componentName.getClassName();
    }

    info.contentDescription = mUserManager.getBadgedLabelForUser(info.title, info.user);
    return info;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:52,代码来源:LoaderCursor.java


示例11: add

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
/**
 * Add the supplied ApplicationInfo objects to the list, and enqueue it into the
 * list to broadcast when notify() is called.
 *
 * If the app is already in the list, doesn't add it.
 */
public void add(AppInfo info, LauncherActivityInfo activityInfo) {
    if (!mAppFilter.shouldShowApp(info.componentName.getPackageName(), mContext)) {
        return;
    }
    if (findActivity(data, info.componentName, info.user)) {
        return;
    }
    mIconCache.getTitleAndIcon(info, activityInfo, true /* useLowResIcon */);

    data.add(info);
    added.add(info);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:19,代码来源:AllAppsList.java


示例12: addPackage

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
/**
 * Add the icons for the supplied apk called packageName.
 */
public void addPackage(Context context, String packageName, UserHandle user) {
    final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(context);
    final List<LauncherActivityInfo> matches = launcherApps.getActivityList(packageName,
            user);

    for (LauncherActivityInfo info : matches) {
        add(new AppInfo(context, info, user), info);
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:13,代码来源:AllAppsList.java


示例13: findActivity

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
/**
 * Returns whether <em>apps</em> contains <em>component</em>.
 */
private static boolean findActivity(List<LauncherActivityInfo> apps,
        ComponentName component) {
    for (LauncherActivityInfo info : apps) {
        if (info.getComponentName().equals(component)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:13,代码来源:AllAppsList.java


示例14: scheduleManagedHeuristicRunnable

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
private void scheduleManagedHeuristicRunnable(final ManagedProfileHeuristic heuristic,
        final UserHandle user, final List<LauncherActivityInfo> apps) {
    if (heuristic != null) {
        // Assume the app lists now is updated.
        mIsManagedHeuristicAppsUpdated = false;
        final Runnable managedHeuristicRunnable = new Runnable() {
            @Override
            public void run() {
                if (mIsManagedHeuristicAppsUpdated) {
                    // If app list is updated, we need to reschedule it otherwise old app
                    // list will override everything in processUserApps().
                    sWorker.post(new Runnable() {
                        public void run() {
                            final List<LauncherActivityInfo> updatedApps =
                                    mLauncherApps.getActivityList(null, user);
                            scheduleManagedHeuristicRunnable(heuristic, user,
                                    updatedApps);
                        }
                    });
                } else {
                    heuristic.processUserApps(apps);
                }
            }
        };
        runOnMainThread(new Runnable() {
            @Override
            public void run() {
                // Check isLoadingWorkspace on the UI thread, as it is updated on the UI
                // thread.
                if (mIsLoadingAndBindingWorkspace) {
                    synchronized (mBindCompleteRunnables) {
                        mBindCompleteRunnables.add(managedHeuristicRunnable);
                    }
                } else {
                    runOnWorkerThread(managedHeuristicRunnable);
                }
            }
        });
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:41,代码来源:LauncherModel.java


示例15: processUserApps

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
/**
 * Checks the list of user apps, and generates package event accordingly.
 * {@see #onLauncherAppsAdded}, {@see #onLauncherPackageRemoved}
 */
void processUserApps(List<LauncherActivityInfo> apps, UserHandle user) {
    String prefKey = INSTALLED_PACKAGES_PREFIX + mUserManager.getSerialNumberForUser(user);
    HashSet<String> oldPackageSet = new HashSet<>();
    final boolean userAppsExisted = getUserApps(oldPackageSet, prefKey);

    HashSet<String> packagesRemoved = new HashSet<>(oldPackageSet);
    HashSet<String> newPackageSet = new HashSet<>();
    ArrayList<LauncherActivityInstallInfo> packagesAdded = new ArrayList<>();

    for (LauncherActivityInfo info : apps) {
        String packageName = info.getComponentName().getPackageName();
        newPackageSet.add(packageName);
        packagesRemoved.remove(packageName);

        if (!oldPackageSet.contains(packageName)) {
            oldPackageSet.add(packageName);
            packagesAdded.add(new LauncherActivityInstallInfo(
                    info, info.getFirstInstallTime()));
        }
    }

    if (!packagesAdded.isEmpty() || !packagesRemoved.isEmpty()) {
        mPrefs.edit().putStringSet(prefKey, newPackageSet).apply();

        if (!packagesAdded.isEmpty()) {
            Collections.sort(packagesAdded);
            onLauncherAppsAdded(packagesAdded, user, userAppsExisted);
        }

        if (!packagesRemoved.isEmpty()) {
            for (String pkg : packagesRemoved) {
                onLauncherPackageRemoved(pkg, user);
            }
        }
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:41,代码来源:CachedPackageTracker.java


示例16: getIconFromHandler

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
private Drawable getIconFromHandler(LauncherActivityInfo info) {
    Bitmap bm = mIconsManager.getDrawableIconForPackage(info.getComponentName());
    if (bm == null) {
        return null;
    }
    return new BitmapDrawable(mContext.getResources(), LauncherIcons.createIconBitmap(bm, mContext));
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:8,代码来源:IconThemer.java


示例17: addCustomInfoToDataBase

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
public void addCustomInfoToDataBase(Drawable icon, ItemInfo info, CharSequence title) {
    LauncherActivityInfo app = mLauncherApps.resolveActivity(info.getIntent(), info.user);
    final ComponentKey key = new ComponentKey(app.getComponentName(), app.getUser());
    CacheEntry entry = mCache.get(key);
    PackageInfo packageInfo = null;
    try {
        packageInfo = mPackageManager.getPackageInfo(
                app.getComponentName().getPackageName(), 0);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    // We can't reuse the entry if the high-res icon is not present.
    if (entry == null || entry.isLowResIcon || entry.icon == null) {
        entry = new CacheEntry();
    }
    entry.icon = LauncherIcons.createIconBitmap(icon, mContext);

    entry.title = title != null ? title : app.getLabel();

    entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, app.getUser());
    mCache.put(key, entry);

    Bitmap lowResIcon = generateLowResIcon(entry.icon, mActivityBgColor);
    ContentValues values = newContentValues(entry.icon, lowResIcon, entry.title.toString(),
            app.getApplicationInfo().packageName);
    if (packageInfo != null) {
        addIconToDB(values, app.getComponentName(), packageInfo,
                mUserManager.getSerialNumberForUser(app.getUser()));
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:31,代码来源:IconCache.java


示例18: updateTitleAndIcon

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
/**
 * Updates {@param application} only if a valid entry is found.
 */
public synchronized void updateTitleAndIcon(AppInfo application) {
    CacheEntry entry = cacheLocked(application.componentName,
            Provider.<LauncherActivityInfo>of(null),
            application.user, false, application.usingLowResIcon);
    if (entry.icon != null && !isDefaultIcon(entry.icon, application.user)) {
        applyCacheEntry(entry, application);
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:12,代码来源:IconCache.java


示例19: getTitleAndIcon

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
/**
 * Fill in {@param info} with the icon and label for {@param activityInfo}
 */
public synchronized void getTitleAndIcon(ItemInfoWithIcon info,
        LauncherActivityInfo activityInfo, boolean useLowResIcon) {

    // If we already have activity info, no need to use package icon
    getTitleAndIcon(info, Provider.of(activityInfo), false, useLowResIcon);
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:10,代码来源:IconCache.java


示例20: SerializedIconUpdateTask

import android.content.pm.LauncherActivityInfo; //导入依赖的package包/类
@Thunk SerializedIconUpdateTask(long userSerial, HashMap<String, PackageInfo> pkgInfoMap,
        Stack<LauncherActivityInfo> appsToAdd,
        Stack<LauncherActivityInfo> appsToUpdate) {
    mUserSerial = userSerial;
    mPkgInfoMap = pkgInfoMap;
    mAppsToAdd = appsToAdd;
    mAppsToUpdate = appsToUpdate;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:9,代码来源:IconCache.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FilteredBlock类代码示例发布时间:2022-05-22
下一篇:
Java SoapFault类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap