• <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 閱讀(403) 評論(0)  編輯 收藏 引用 所屬分類: Android開發
            亚洲国产成人久久精品动漫| 色综合久久久久综合体桃花网| 国产情侣久久久久aⅴ免费| 久久久婷婷五月亚洲97号色| 国产91色综合久久免费| A级毛片无码久久精品免费| 久久久久九九精品影院| 一本色道久久88精品综合| 色偷偷888欧美精品久久久| 久久久精品人妻一区二区三区蜜桃| 99久久精品日本一区二区免费| 久久国产视屏| 久久丫精品国产亚洲av| 国产视频久久| 久久99精品国产一区二区三区| 精品伊人久久久| 久久精品国产亚洲沈樵| 亚洲中文字幕久久精品无码喷水| 久久亚洲精品中文字幕三区| 久久久国产打桩机| 精品无码人妻久久久久久| 久久国产精品一国产精品金尊| 无码人妻少妇久久中文字幕| 久久777国产线看观看精品| 国产亚洲美女精品久久久2020| 国产激情久久久久影院小草| 97久久香蕉国产线看观看| 国产A三级久久精品| 久久久久久精品免费看SSS| 久久久久亚洲AV无码专区网站| 一级做a爰片久久毛片16| 99久久久国产精品免费无卡顿| 亚洲狠狠婷婷综合久久蜜芽| 亚洲精品午夜国产va久久| 久久精品三级视频| 久久性精品| 女人高潮久久久叫人喷水| 亚洲欧美成人久久综合中文网 | 国内精品久久久久影院亚洲| 国产精品热久久无码av| 91久久福利国产成人精品|