List of usage examples for android.content ComponentName unflattenFromString
public static @Nullable ComponentName unflattenFromString(@NonNull String str)
From source file:com.farmerbb.taskbar.activity.ContextMenuActivity.java
@TargetApi(Build.VERSION_CODES.N_MR1) private int getLauncherShortcuts() { LauncherApps launcherApps = (LauncherApps) getSystemService(LAUNCHER_APPS_SERVICE); if (launcherApps.hasShortcutHostPermission()) { UserManager userManager = (UserManager) getSystemService(USER_SERVICE); LauncherApps.ShortcutQuery query = new LauncherApps.ShortcutQuery(); query.setActivity(ComponentName.unflattenFromString(componentName)); query.setQueryFlags(//from ww w . ja v a2 s . c o m LauncherApps.ShortcutQuery.FLAG_MATCH_DYNAMIC | LauncherApps.ShortcutQuery.FLAG_MATCH_MANIFEST | LauncherApps.ShortcutQuery.FLAG_MATCH_PINNED); shortcuts = launcherApps.getShortcuts(query, userManager.getUserForSerialNumber(userId)); if (shortcuts != null) return shortcuts.size(); } return 0; }
From source file:com.google.android.apps.muzei.api.MuzeiArtSource.java
private void loadSubscriptions() { mSubscriptions = new HashMap<ComponentName, String>(); Set<String> serializedSubscriptions = mSharedPrefs.getStringSet(PREF_SUBSCRIPTIONS, null); if (serializedSubscriptions != null) { for (String serializedSubscription : serializedSubscriptions) { String[] arr = serializedSubscription.split("\\|", 2); ComponentName subscriber = ComponentName.unflattenFromString(arr[0]); String token = arr[1]; mSubscriptions.put(subscriber, token); }//from ww w . j a va 2 s . c om } }
From source file:org.deviceconnect.android.manager.DConnectMessageService.java
/** * ??.//from w w w . jav a2s . c om * @param receiver ??BroadcastReceiver * @param event ?? */ public void sendEvent(final String receiver, final Intent event) { if (BuildConfig.DEBUG) { mLogger.info(String.format("sendEvent: %s intent: %s", receiver, event.getExtras())); } Intent targetIntent = new Intent(event); targetIntent.setComponent(ComponentName.unflattenFromString(receiver)); sendBroadcast(targetIntent); }
From source file:ca.mimic.apphangar.Settings.java
public static synchronized void rebuildIconCache(final List<AppsRowItem> appTasks) { Runnable runnable = new Runnable() { @Override/*from w w w . jav a 2s .c o m*/ public void run() { IconHelper ih = new IconHelper(mContext); for (AppsRowItem task : appTasks) { ComponentName componentName = ComponentName .unflattenFromString(task.getPackageName() + "/" + task.getClassName()); ih.cachedIconHelper(componentName); } Tools.updateWidget(mContext); myService.execute(SERVICE_CREATE_NOTIFICATIONS); } }; new Thread(runnable).start(); }
From source file:com.linkbubble.Settings.java
public ResolveInfo getDefaultAppForUrl(URL url, List<ResolveInfo> resolveInfos) { if (resolveInfos == null || resolveInfos.size() == 0) { return null; }/*from w w w.ja va2 s . co m*/ String host = url.getHost(); if (host.length() > 1) { String flattenedComponentName = mDefaultAppsMap.get(host); if (flattenedComponentName != null) { ComponentName componentName = ComponentName.unflattenFromString(flattenedComponentName); if (componentName != null) { for (ResolveInfo resolveInfo : resolveInfos) { // Handle crash: https://fabric.io/brave6/android/apps/com.linkbubble.playstore/issues/5623e787f5d3a7f76be5b166 if (resolveInfo == null || resolveInfo.activityInfo == null) { CrashTracking.log("Null resolveInfo when getting default for app: " + resolveInfo); continue; } if (resolveInfo.activityInfo.packageName.equals(componentName.getPackageName()) && resolveInfo.activityInfo.name.equals(componentName.getClassName())) { return resolveInfo; } } if (componentName.getPackageName().equals(mContext.getPackageName())) { return mLinkBubbleEntryActivityResolveInfo; } } } } return null; }
From source file:com.linkbubble.Settings.java
public TreeMap<String, ComponentName> getDefaultAppsMap() { if (mDefaultAppsMap != null && mDefaultAppsMap.size() > 0) { TreeMap<String, ComponentName> result = new TreeMap<String, ComponentName>(); for (String host : mDefaultAppsMap.keySet()) { result.put(host, ComponentName.unflattenFromString(mDefaultAppsMap.get(host))); }/*from w w w . j av a 2 s . co m*/ return result; } return null; }
From source file:org.deviceconnect.android.deviceplugin.host.HostDeviceService.java
/** * ./*from w ww.jav a 2 s .c o m*/ * * @param mediaId ID * @param uri ??URI */ public void notifyDataAvailable(final String mediaId, final String uri) { List<Event> evts = EventManager.INSTANCE.getEventList(mDeviceId, MediaStreamRecordingProfileConstants.PROFILE_NAME, null, MediaStreamRecordingProfileConstants.ATTRIBUTE_ON_DATA_AVAILABLE); for (Event evt : evts) { Bundle media = new Bundle(); media.putString(MediaStreamRecordingProfile.PARAM_PATH, mediaId); media.putString(MediaStreamRecordingProfile.PARAM_URI, uri); media.putString(MediaStreamRecordingProfile.PARAM_MIME_TYPE, "image/jpg"); Intent intent = new Intent(IntentDConnectMessage.ACTION_EVENT); intent.setComponent(ComponentName.unflattenFromString(evt.getReceiverName())); intent.putExtra(DConnectMessage.EXTRA_DEVICE_ID, DEVICE_ID); intent.putExtra(DConnectMessage.EXTRA_PROFILE, MediaStreamRecordingProfile.PROFILE_NAME); intent.putExtra(DConnectMessage.EXTRA_ATTRIBUTE, MediaStreamRecordingProfile.ATTRIBUTE_ON_DATA_AVAILABLE); intent.putExtra(DConnectMessage.EXTRA_SESSION_KEY, evt.getSessionKey()); intent.putExtra(MediaStreamRecordingProfile.PARAM_MEDIA, media); sendEvent(intent, evt.getAccessToken()); } }
From source file:ca.mimic.apphangar.Settings.java
public static List<AppsRowItem> createAppTasks() { db = TasksDataSource.getInstance(mContext); db.open();/*w w w . ja v a2 s .c o m*/ int highestSeconds = db.getHighestSeconds(); List<TasksModel> tasks = db.getAllTasks(); List<AppsRowItem> appTasks = new ArrayList<AppsRowItem>(); for (TasksModel task : tasks) { try { try { ComponentName.unflattenFromString(task.getPackageName() + "/" + task.getClassName()); } catch (Exception e) { Tools.HangarLog("Could not find Application info for [" + task.getName() + "]"); db.deleteTask(task); continue; } if (new Tools().cachedImageResolveInfo(mContext, task.getPackageName()) != null) appTasks.add(createAppRowItem(task, highestSeconds)); } catch (Exception e) { Tools.HangarLog("could not add taskList item " + e); } SharedPreferences prefs2 = prefs.prefsGet(); Collections.sort(appTasks, new Tools.AppRowComparator(prefs2.getInt(APPLIST_TOP_PREFERENCE, APPLIST_TOP_DEFAULT), prefs2.getInt(APPLIST_SORT_PREFERENCE, APPLIST_SORT_DEFAULT))); } db.close(); return appTasks; }
From source file:ca.mimic.apphangar.Settings.java
public static AppsRowItem createAppRowItem(TasksModel task, int highestSeconds) { AppsRowItem appTask = new AppsRowItem(task); float secondsRatio = (float) task.getSeconds() / highestSeconds; int barColor; int secondsColor = (Math.round(secondsRatio * 100)); if (secondsColor >= 80) { barColor = 0xFF34B5E2;//from w ww .j a v a 2s. c om } else if (secondsColor >= 60) { barColor = 0xFFAA66CC; } else if (secondsColor >= 40) { barColor = 0xFF74C353; } else if (secondsColor >= 20) { barColor = 0xFFFFBB33; } else { barColor = 0xFFFF4444; } int[] statsTime = splitToComponentTimes(task.getSeconds()); String statsString = ((statsTime[0] > 0) ? statsTime[0] + "h " : "") + ((statsTime[1] > 0) ? statsTime[1] + "m " : "") + ((statsTime[2] > 0) ? statsTime[2] + "s " : ""); int maxWidth = displayWidth - Tools.dpToPx(mContext, 46 + 14 + 90); float adjustedWidth = maxWidth * secondsRatio; ComponentName componentTask = ComponentName .unflattenFromString(task.getPackageName() + "/" + task.getClassName()); appTask.setComponentName(componentTask); appTask.setPinned(new Tools().isPinned(mContext, task.getPackageName())); appTask.setStats(statsString); appTask.setBarColor(barColor); appTask.setBarContWidth(Math.round(adjustedWidth)); return appTask; }
From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java
private void updateProtectedAppsList(Context context) { String protectedComponents = Settings.Secure.getString(context.getContentResolver(), LauncherModel.SETTINGS_PROTECTED_COMPONENTS); protectedComponents = protectedComponents == null ? "" : protectedComponents; String[] flattened = protectedComponents.split("\\|"); mProtectedApps = new ArrayList<ComponentName>(flattened.length); mProtectedPackages = new ArrayList<String>(flattened.length); for (String flat : flattened) { ComponentName cmp = ComponentName.unflattenFromString(flat); if (cmp != null) { mProtectedApps.add(cmp);// w w w .j a v a 2 s . c o m mProtectedPackages.add(cmp.getPackageName()); } } }