編輯:關於Android編程
/**
* 是否已創建快捷方式
* @return
*/
private boolean hasShortcut()
{
boolean isInstallShortcut = false;
final String AUTHORITY ="com.android.launcher.settings";
final Uri CONTENT_URI = Uri.parse("content://" +AUTHORITY + "/favorites?notify=true");
Cursor c = getContentResolver().query(CONTENT_URI, new String[] {"title", "iconResource" }, "title=?", new String[] {shopDetail.getTitle()}, null);
if(null != c && c.getCount() > 0)
{
isInstallShortcut = true ;
}
return isInstallShortcut;
}
/**
* 創建快捷方式
*/
private void addShortcut()
{
if (hasShortcut())
{
return;
}
Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
//快捷方式的名稱
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, shopDetail.getTitle() + "的店鋪");
//不允許重復創建
shortcut.putExtra("duplicate", false);
//指定當前的Activity為快捷方式啟動的對象:
ComponentName comp = new ComponentName("com.itel.platform", "com.itel.platform"+"."+"ui.shop.ShopIndexActivity");
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).putExtra("shopId", uShopId).putExtra("openType", 1).setComponent(comp));
//快捷方式的圖標,可以添加兩種類型
if (bitmap != null) {
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);//有圖片就用圖片,沒有就用當前App圖片
} else {
Parcelable icon = Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);//set the icon
}
//有的android版本不提示,這裡手動提示
if (Build.VERSION.SDK_INT == 10 || Build.VERSION.SDK_INT >= 19) {
T.s(context, "快捷鍵 " + shopDetail.getTitle() + "的店鋪 己添加");
}
sendBroadcast(shortcut);
}
[Android] 隱藏虛擬導航鍵
在Android API 19+ 的設備上可以通過呼叫如下方法隱藏虛擬按鍵: @SuppressLint("NewApi") privat
Android TV磁貼類app自動化框架二次改造(基於UiAutomator)
簡介 項目一直是手工測試為主,加上一直是TV類應用,很多自動化工具都沒有針對TV類項目做很好的適配,所以只有自己動手了。主要針對項目的特殊性進行了部分改造,不一定適用於其
Android 塗鴉最佳實踐
Android中實現手勢畫圖一般都兩種方式,一是直接在View上繪制,而是使用SurfaceView。兩者還是有一些差別的。簡介下。View:顯示視圖,內置畫布,提供圖形
初探Google推薦Android圖片加載框架Glide
簡介現在在Android上加載圖片的框架都已經爛大街了,所以我們這裡也不說誰好誰壞,當然也不做比較了,因為得出的結果都是片面的,沒有誰好誰壞只有適不適合需求罷了起因是在泰
Android源碼淺析(三)——Android AOSP 5.1.1源碼的同步sync和編譯make,搭建Samba服務器進行更便捷的燒錄刷機
最近比較忙,而且又要維護自己的博客,視頻和公眾號,也就沒仔細的梳理源碼