ComponentName flattenToShortString - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ComponentName flattenToShortString method.

This code example shows how to use the following methods:flattenToShortString
     * @return A drawable, or {@code null} if neither the activity nor the application 
     *         has an icon set. 
     */ 
    private Drawable getActivityIconWithCache(ComponentName component) {
        // First check the icon cache 
        String componentIconKey = component.flattenToShortString();
        // Using containsKey() since we also store null values. 
        if (mOutsideDrawablesCache.containsKey(componentIconKey)) {
            Drawable.ConstantState cached = mOutsideDrawablesCache.get(componentIconKey);
            return cached == null ? null : cached.newDrawable(mProviderContext.getResources());
        } 
        // Then try the activity or application icon 
        Drawable drawable = getActivityIcon(component);
        // Stick it in the cache so we don't do this lookup again. 
        Drawable.ConstantState toCache = drawable == null ? null : drawable.getConstantState();
        mOutsideDrawablesCache.put(componentIconKey, toCache);
        return drawable;
    } 
 
    /** 
6
CodeRank
This code example shows how to use the following methods:flattenToShortString
     * @return A drawable, or {@code null} if neither the activity nor the application 
     *         has an icon set. 
     */ 
    private Drawable getActivityIconWithCache(ComponentName component) {
        // First check the icon cache 
        String componentIconKey = component.flattenToShortString();
        // Using containsKey() since we also store null values. 
        if (mOutsideDrawablesCache.containsKey(componentIconKey)) {
            Drawable.ConstantState cached = mOutsideDrawablesCache.get(componentIconKey);
            return cached == null ? null : cached.newDrawable(mProviderContext.getResources());
        } 
        // Then try the activity or application icon 
        Drawable drawable = getActivityIcon(component);
        // Stick it in the cache so we don't do this lookup again. 
        Drawable.ConstantState toCache = drawable == null ? null : drawable.getConstantState();
        mOutsideDrawablesCache.put(componentIconKey, toCache);
        return drawable;
    } 
 
    /** 
6
CodeRank
This code example shows how to use the following methods:flattenToShortString
 
    // Called on the main thread 
    private void storeShortcut(ComponentName sourceComponent, ContentValues shortcut) {
        if (DBG) Log.d(TAG, "Adding (PID: " + Binder.getCallingPid() + "): " + shortcut);
 
        Source source = getCorpora().getSource(sourceComponent.flattenToShortString());
        if (source == null) {
            Log.w(TAG, "Unknown shortcut source " + sourceComponent);
            return; 
        } 
 
        String userQuery = shortcut.getAsString(SearchManager.USER_QUERY);
        if (userQuery == null) userQuery = "";
 
        ListSuggestionCursor cursor = new ListSuggestionCursor(userQuery);
        cursor.add(makeSuggestion(source, shortcut));
        getShortcutRepository().reportClick(cursor, 0);
    } 
 
    private boolean checkCallingPackage(String packageName) {
6
CodeRank
This code example shows how to use the following methods:flattenToShortString
            NamedTaskExecutor iconLoader) throws NameNotFoundException {
        super(context, uiThread, iconLoader);
        ComponentName componentName = searchable.getSearchActivity();
        if (DBG) Log.d(TAG, "created Searchable for " + componentName);
        mSearchable = searchable;
        mName = componentName.flattenToShortString();
        PackageManager pm = context.getPackageManager();
        mActivityInfo = pm.getActivityInfo(componentName, 0);
        PackageInfo pkgInfo = pm.getPackageInfo(componentName.getPackageName(), 0);
        mVersionCode = pkgInfo.versionCode;
    } 
 
    public SearchableInfo getSearchableInfo() {
        return mSearchable;
    } 
 
    /** 
     * Checks if the current process can read the suggestion provider in this source. 
     */ 
    public boolean canRead() { 
5
CodeRank
This code example shows how to use the following methods:flattenToShortString
                    pw.print(" bad="); pw.print(bad);
 
                    // crashing or notResponding is always set before errorReportReceiver 
                    if (errorReportReceiver != null) {
                        pw.print(" errorReportReceiver=");
                        pw.print(errorReportReceiver.flattenToShortString());
                    } 
                    pw.println();
        } 
        if (activities.size() > 0) {
            pw.print(prefix); pw.print("activities="); pw.println(activities);
        } 
        if (services.size() > 0) {
            pw.print(prefix); pw.print("services="); pw.println(services);
        } 
        if (executingServices.size() > 0) {
            pw.print(prefix); pw.print("executingServices="); pw.println(executingServices);
        } 
        if (connections.size() > 0) {
            pw.print(prefix); pw.print("connections="); pw.println(connections);
5
CodeRank
This code example shows how to use the following methods:flattenToShortString
                    pw.print(" bad="); pw.print(bad);
 
                    // crashing or notResponding is always set before errorReportReceiver 
                    if (errorReportReceiver != null) {
                        pw.print(" errorReportReceiver=");
                        pw.print(errorReportReceiver.flattenToShortString());
                    } 
                    pw.println();
        } 
        if (activities.size() > 0) {
            pw.print(prefix); pw.print("activities="); pw.println(activities);
        } 
        if (services.size() > 0) {
            pw.print(prefix); pw.print("services="); pw.println(services);
        } 
        if (executingServices.size() > 0) {
            pw.print(prefix); pw.print("executingServices="); pw.println(executingServices);
        } 
        if (connections.size() > 0) {
            pw.print(prefix); pw.print("connections="); pw.println(connections);
5
CodeRank
This code example shows how to use the following methods:flattenToShortString
 
    private SearchableInfo getSearchable(ComponentName componentName) {
        SearchableInfo searchable = mSearchManager.getSearchableInfo(componentName);
        if (searchable == null || searchable.getSuggestAuthority() == null) {
            throw new RuntimeException("Component is not searchable: "
                    + componentName.flattenToShortString());
        } 
        return searchable;
    } 
 
    /** 
     * Keeps track of timings in nanoseconds. 
     */ 
    private static class ElapsedTime { 
        private long mTotal = 0;
        private int mCount = 0;
        public synchronized void addTime(long time) {
            mTotal += time;
            mCount++;
        } 
4
CodeRank
This code example shows how to use the following methods:flattenToShortString
            out.attribute(null, "width", Integer.toString(mWidth));
            out.attribute(null, "height", Integer.toString(mHeight));
            out.attribute(null, "name", mName);
            if (mWallpaperComponent != null) {
                out.attribute(null, "component",
                        mWallpaperComponent.flattenToShortString());
            } 
            out.endTag(null, "wp");
 
            out.endDocument();
            stream.close();
            journal.commit();
        } catch (IOException e) {
            try { 
                if (stream != null) {
                    stream.close();
                } 
            } catch (IOException ex) {
                // Ignore 
            } 
3
CodeRank

Related ComponentName flattenToShortString Questions & Answers:

flattenToShortString Method Overview
The same as flattenToString(), but abbreviates the class name if it is a suffix of the package.
See Code Examples for other Android ComponentName Methods: