• <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開發
            久久性生大片免费观看性| 亚洲精品无码久久久久| 99re久久精品国产首页2020| 99热成人精品热久久669| 久久99精品久久只有精品| 97精品依人久久久大香线蕉97| 精品无码久久久久久尤物| 国产农村妇女毛片精品久久| 国产成人精品综合久久久久| 国产香蕉97碰碰久久人人| 国产A级毛片久久久精品毛片| 久久青草国产精品一区| 久久精品免费一区二区| 久久免费精品一区二区| 新狼窝色AV性久久久久久| 久久久WWW成人| 99久久精品影院老鸭窝| 中文字幕久久亚洲一区| 国产69精品久久久久99尤物| 亚洲va久久久噜噜噜久久| 青青热久久国产久精品| 久久国产精品久久国产精品| 色欲久久久天天天综合网| 热综合一本伊人久久精品| 嫩草影院久久99| 久久青草国产精品一区| 99久久国产热无码精品免费| 久久夜色精品国产噜噜亚洲AV| 无码八A片人妻少妇久久| 久久久久黑人强伦姧人妻| 国产成人无码精品久久久久免费| 日韩精品久久无码人妻中文字幕| 模特私拍国产精品久久| 欧美一级久久久久久久大片| 久久99精品久久久久久野外 | 热综合一本伊人久久精品 | 久久精品国产一区二区三区不卡| 久久久久AV综合网成人| 色狠狠久久AV五月综合| 久久99精品久久久久久hb无码 | 久久精品一区二区|