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


Java ActivityManager.getLauncherLargeIconDensity方法代码示例

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


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

示例1: generateHomeScreenIcon

import android.app.ActivityManager; //导入方法依赖的package包/类
/**
 * Generates a generic icon to be used in the launcher. This is just a rounded rectangle with
 * a letter in the middle taken from the website's domain name.
 *
 * @param url URL of the shortcut.
 * @param red Red component of the dominant icon color.
 * @param green Green component of the dominant icon color.
 * @param blue Blue component of the dominant icon color.
 * @return Bitmap Either the touch-icon or the newly created favicon.
 */
@CalledByNative
public static Bitmap generateHomeScreenIcon(String url, int red, int green, int blue) {
    Context context = ContextUtils.getApplicationContext();
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    final int outerSize = am.getLauncherLargeIconSize();
    final int iconDensity = am.getLauncherLargeIconDensity();

    Bitmap bitmap = null;
    try {
        bitmap = Bitmap.createBitmap(outerSize, outerSize, Bitmap.Config.ARGB_8888);
    } catch (OutOfMemoryError e) {
        Log.w(TAG, "OutOfMemoryError while trying to draw bitmap on canvas.");
        return null;
    }

    Canvas canvas = new Canvas(bitmap);

    // Draw the drop shadow.
    int padding = (int) (GENERATED_ICON_PADDING_RATIO * outerSize);
    Rect outerBounds = new Rect(0, 0, outerSize, outerSize);
    Bitmap iconShadow =
            getBitmapFromResourceId(context, R.mipmap.shortcut_icon_shadow, iconDensity);
    Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(iconShadow, null, outerBounds, paint);

    // Draw the rounded rectangle and letter.
    int innerSize = outerSize - 2 * padding;
    int cornerRadius = Math.round(ICON_CORNER_RADIUS_RATIO * outerSize);
    int fontSize = Math.round(GENERATED_ICON_FONT_SIZE_RATIO * outerSize);
    int color = Color.rgb(red, green, blue);
    RoundedIconGenerator generator = new RoundedIconGenerator(
            innerSize, innerSize, cornerRadius, color, fontSize);
    Bitmap icon = generator.generateIconForUrl(url);
    if (icon == null) return null; // Bookmark URL does not have a domain.
    canvas.drawBitmap(icon, padding, padding, null);

    return bitmap;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:49,代码来源:ShortcutHelper.java

示例2: onCreate

import android.app.ActivityManager; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState, Intent intent,
                            CharSequence title, Intent[] initialIntents, List<ResolveInfo> rList,
                            boolean alwaysUseOption, int userid) {
        super.onCreate(savedInstanceState);
        mLaunchedFromUid = userid;
        mPm = getPackageManager();
        mAlwaysUseOption = alwaysUseOption;
        mMaxColumns = getResources().getInteger(R.integer.config_maxResolverActivityColumns);

        mRegistered = true;

        final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
        mIconDpi = am.getLauncherLargeIconDensity();
        mIconSize = am.getLauncherLargeIconSize();

        mAdapter = new ResolveListAdapter(this, intent, initialIntents, rList,
                mLaunchedFromUid);
        int count = mAdapter.getCount();
        if (Build.VERSION.SDK_INT >= 17) {
            if (mLaunchedFromUid < 0) {
                // Gulp!
                finish();
                return;
            }
        }

        if (count == 1) {
            startSelected(0, false);
            mRegistered = false;
            finish();
            return;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(title);
        if (count > 1) {
            mListView = new ListView(this);
            mListView.setAdapter(mAdapter);
            mListView.setOnItemClickListener(this);
            mListView.setOnItemLongClickListener(new ItemLongClickListener());
            builder.setView(mListView);
            if (alwaysUseOption) {
                mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
            }
        } else {
            builder.setMessage(R.string.noApplications);
        }
        builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                finish();
            }
        });
        dialog = builder.show();
//
//        if (alwaysUseOption) {
//            final ViewGroup buttonLayout = (ViewGroup) findViewById(R.id.button_bar);
//            if (buttonLayout != null) {
//                buttonLayout.setVisibility(View.VISIBLE);
//                mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);
//                mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once);
//            } else {
//                mAlwaysUseOption = false;
//            }
//            // Set the initial highlight if there was a preferred or last used choice
//            final int initialHighlight = mAdapter.getInitialHighlight();
//            if (initialHighlight >= 0) {
//                mListView.setItemChecked(initialHighlight, true);
//                onItemClick(null, null, initialHighlight, 0); // Other entries are not used
//            }
//        }
    }
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:72,代码来源:ResolverActivity.java

示例3: onCreate

import android.app.ActivityManager; //导入方法依赖的package包/类
protected void onCreate(Bundle savedInstanceState, Intent intent,
                            CharSequence title, Intent[] initialIntents, List<ResolveInfo> rList,
                            boolean alwaysUseOption,int userid) {
        super.onCreate(savedInstanceState);
        mLaunchedFromUid = userid;
        mPm = getPackageManager();
        mAlwaysUseOption = alwaysUseOption;
        mMaxColumns = getResources().getInteger(R.integer.config_maxResolverActivityColumns);

        mRegistered = true;

        final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
        mIconDpi = am.getLauncherLargeIconDensity();
        mIconSize = am.getLauncherLargeIconSize();

        mAdapter = new ResolveListAdapter(this, intent, initialIntents, rList,
                mLaunchedFromUid);
        int count = mAdapter.getCount();
        if (Build.VERSION.SDK_INT >= 17) {
            if (mLaunchedFromUid < 0) {
                // Gulp!
                finish();
                return;
            }
        }

        if (count == 1) {
            startSelected(0, false);
            mRegistered = false;
            finish();
            return;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(title);
        if (count > 1) {
            mListView = new ListView(this);
            mListView.setAdapter(mAdapter);
            mListView.setOnItemClickListener(this);
            mListView.setOnItemLongClickListener(new ItemLongClickListener());
            builder.setView(mListView);
            if (alwaysUseOption) {
                mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
            }
        } else {
            builder.setMessage(R.string.noApplications);
        }
        builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
                finish();
            }
        });
        dialog = builder.show();
//
//        if (alwaysUseOption) {
//            final ViewGroup buttonLayout = (ViewGroup) findViewById(R.id.button_bar);
//            if (buttonLayout != null) {
//                buttonLayout.setVisibility(View.VISIBLE);
//                mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);
//                mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once);
//            } else {
//                mAlwaysUseOption = false;
//            }
//            // Set the initial highlight if there was a preferred or last used choice
//            final int initialHighlight = mAdapter.getInitialHighlight();
//            if (initialHighlight >= 0) {
//                mListView.setItemChecked(initialHighlight, true);
//                onItemClick(null, null, initialHighlight, 0); // Other entries are not used
//            }
//        }
    }
 
开发者ID:codehz,项目名称:container,代码行数:72,代码来源:ResolverActivity.java


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