• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            life02

              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
              197 隨筆 :: 3 文章 :: 37 評論 :: 0 Trackbacks

            AnyCat 是android一個小的項目,雖然麻雀很小但是知識很多。別看小程序就沒學習的地方,錯也。現將學習總結如下:以下為AnyCat項目精髓之處。

            轉載請注明:QQ:273733055 ppwuyi@sohu.com

            程序核心代碼如下:
            http://hi.baidu.com/adnroidorg/blog/item/b79194a4c424809bd14358ba.html

            /****
            *      result.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
            *     result.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); //-----------廣播接收者
            *     result.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); //---------------加載進去
            *     result.putExtra(Intent.EXTRA_SHORTCUT_NAME, info.loadLabel(mPackageManager));//------------獲取名字 地址路徑
            *     result.putExtra(Intent.EXTRA_SHORTCUT_ICON, bd.getBitmap());//----------------加載進去
            */
            sendBroadcast(result);  //注意這才是創建快接方式的核心地點

            將裝配好的Intent通過廣播的形式發送到com.android.launcher.action.INSTALL_SHORTCUT;

            不過中小功能的地方我們也學習到不少,現總結如下:
            1. FrontDoorActivity.java  無學習要點。
            2 .ActivityPickerActivity.java  學習到怎么獲取系統應用程序的程序名和路徑。
            view.setTag(view.findViewById(android.R.id.text1));
            final TextView textView = (TextView) view.getTag();

            Intent queryIntent = new Intent(Intent.ACTION_MAIN); //過濾地址
            List<ResolveInfo> list = mPackageManager.queryIntentActivities(queryIntent, 0); //返回符合 地址要求的列表

            textView.setText(info.getInfo().loadLabel(mPackageManager)); //取出項目名
            mPackageManager = getPackageManager();//獲取包

            //獲取應用程序的圖標
            Drawable drawable = info.loadIcon(mPackageManager); //---------------------------讀取程序圖標
            if (drawable instanceof BitmapDrawable) {
            BitmapDrawable bd = (BitmapDrawable) drawable;
            result.putExtra(Intent.EXTRA_SHORTCUT_ICON, bd.getBitmap());//----------------加載進去
            }
            //獲取鏈接應用程序的橋梁
            Intent intent = new Intent();//準備
            intent.setComponent(new ComponentName(info.activityInfo.applicationInfo.packageName,
            info.activityInfo.name));  //這是核心

            轉載請注明:QQ:273733055 ppwuyi@sohu.com


            3.CreateShortcutActivity.java  學習到很多東西
            //獲取單一的聯系人
            Intent intent = new Intent(Intent.ACTION_PICK, Phones.CONTENT_URI);  //顯示聯系人列表并重中選擇一個聯系人的URI鏈接方式
            intent.putExtra(Contacts.Intents.UI.TITLE_EXTRA_KEY, getText(R.string.callShortcutActivityTitle)); //傳遞一個標題給聯系人列表
            startActivityForResult(intent, REQUEST_PHONE);//開啟聯系人選擇的activity等待用戶選擇

            //別樣的構造函數
            return new ShortcutEditorDialog(this, this, this); //注意這個this,this,this 應為實現了onClick,onCancel接口
            public ShortcutEditorDialog(Context context, OnClickListener onClick, OnCancelListener onCancel){.....}

            //很和諧的代碼
            int iconSize = (int) r.getDimension(android.R.dimen.app_icon_size);//獲得當前系統快捷方式的圖片的限制大小
            Bitmap icon = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888); //建立一個空的BItMap
            Canvas canvas = new Canvas(icon);//初始化畫布 繪制的圖像到icon上

            // Copy in the photo
            Paint photoPaint = new Paint(); //建立畫筆
            photoPaint.setDither(true); //獲取跟清晰的圖像采樣
            photoPaint.setFilterBitmap(true);//過濾一些
            Rect src = new Rect(0, 0, photo.getWidth(), photo.getHeight());//創建一個指定的新矩形的坐標
            Rect dst = new Rect(0, 0, iconSize, iconSize);//創建一個指定的新矩形的坐標
            canvas.drawBitmap(photo, src, dst, photoPaint);//將photo 縮放或則擴大到 dst使用的填充區photoPaint

            //再次被和諧的代碼
            Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);//設置畫筆
            textPaint.setTextSize(20.0f);//字體大小
            textPaint.setTypeface(Typeface.DEFAULT_BOLD);//采用默認的寬度
            textPaint.setColor(r.getColor(R.color.textColorIconOverlay));//采用的顏色
            textPaint.setShadowLayer(3f, 1, 1, r.getColor(R.color.textColorIconOverlayShadow));//影音的設置
            canvas.drawText(overlay, 2, 16, textPaint);//繪制上去 字,開始未知x,y采用那只筆繪制


            4.ShortcutEditorDialog.java
            唯一學習到了一點是 
            mNameView.setError(getContext().getText(R.string.errorEmptyName));//顯示輸入框為空的告警
            想看效果自己動手吧。
            posted on 2012-03-21 15:03 life02 閱讀(408) 評論(0)  編輯 收藏 引用 所屬分類: Android開發
            久久人搡人人玩人妻精品首页 | 精品一久久香蕉国产线看播放| 日韩人妻无码精品久久免费一 | 久久99久久99小草精品免视看| 中文字幕成人精品久久不卡| 久久亚洲色一区二区三区| 亚洲精品NV久久久久久久久久| 无码精品久久久天天影视| 久久精品九九亚洲精品天堂| 久久青青色综合| 国产精品久久久99| 无码日韩人妻精品久久蜜桃| 久久e热在这里只有国产中文精品99 | 久久久婷婷五月亚洲97号色| 精品水蜜桃久久久久久久| 久久精品九九亚洲精品| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 久久精品aⅴ无码中文字字幕不卡 久久精品aⅴ无码中文字字幕重口 | 亚洲国产精品久久久久久| 伊人久久大香线蕉AV一区二区| 久久99国产精品二区不卡| 伊人色综合久久天天人手人婷| 久久精品国产只有精品66| 久久夜色精品国产亚洲| 久久w5ww成w人免费| 精品综合久久久久久98| 偷偷做久久久久网站| 久久天天日天天操综合伊人av| 伊人久久精品线影院| 色成年激情久久综合| 久久香蕉综合色一综合色88| 国产精品久久午夜夜伦鲁鲁| 色婷婷久久综合中文久久蜜桃av| 久久91这里精品国产2020| 91精品国产91久久久久久蜜臀| 国产精品久久久久…| 久久777国产线看观看精品| 久久亚洲欧美日本精品| 国产精品久久久久久久久久免费| 精品久久久久中文字| 久久天天日天天操综合伊人av|