當前位置: 首頁>>代碼示例>>Java>>正文


Java ShortcutIconResource類代碼示例

本文整理匯總了Java中android.content.Intent.ShortcutIconResource的典型用法代碼示例。如果您正苦於以下問題:Java ShortcutIconResource類的具體用法?Java ShortcutIconResource怎麽用?Java ShortcutIconResource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ShortcutIconResource類屬於android.content.Intent包,在下文中一共展示了ShortcutIconResource類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createIconBitmap

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
/**
 * Returns a bitmap suitable for the all apps view. If the package or the resource do not
 * exist, it returns null.
 */
public static Bitmap createIconBitmap(ShortcutIconResource iconRes, Context context) {
    PackageManager packageManager = context.getPackageManager();
    // the resource
    try {
        Resources resources = packageManager.getResourcesForApplication(iconRes.packageName);
        if (resources != null) {
            final int id = resources.getIdentifier(iconRes.resourceName, null, null);
            return createIconBitmap(resources.getDrawableForDensity(
                    id, LauncherAppState.getIDP(context).fillResIconDpi, context.getTheme()), context);
        }
    } catch (Exception e) {
        // Icon not found.
    }
    return null;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:20,代碼來源:LauncherIcons.java

示例2: loadIcon

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
/**
 * Loads the icon from the cursor and updates the {@param info} if the icon is an app resource.
 */
private Bitmap loadIcon(ShortcutInfo info) {
    Bitmap icon = null;
    if (itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
        String packageName = getString(iconPackageIndex);
        String resourceName = getString(iconResourceIndex);
        if (!TextUtils.isEmpty(packageName) || !TextUtils.isEmpty(resourceName)) {
            info.iconResource = new ShortcutIconResource();
            info.iconResource.packageName = packageName;
            info.iconResource.resourceName = resourceName;
            icon = LauncherIcons.createIconBitmap(info.iconResource, mContext);
        }
    }
    if (icon == null) {
        // Failed to load from resource, try loading from DB.
        byte[] data = getBlob(iconIndex);
        try {
            icon = LauncherIcons.createIconBitmap(
                    BitmapFactory.decodeByteArray(data, 0, data.length), mContext);
        } catch (Exception e) {
            return null;
        }
    }
    return icon;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:28,代碼來源:LoaderCursor.java

示例3: a

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
public static void a(Context context, String str, String str2, int i) {
    Uri parse = Uri.parse(str2);
    if (parse == null) {
        new StringBuilder(z[34]).append(str2);
        z.b();
        return;
    }
    Parcelable intent = new Intent(z[23], parse);
    intent.setFlags(335544320);
    Parcelable fromContext = ShortcutIconResource.fromContext(context, i);
    Intent intent2 = new Intent(z[30]);
    intent2.putExtra(z[33], false);
    intent2.putExtra(z[35], str);
    intent2.putExtra(z[32], intent);
    intent2.putExtra(z[31], fromContext);
    context.sendBroadcast(intent2);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:18,代碼來源:a.java

示例4: loadIcon

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
/**
 * Loads the icon from the cursor and updates the {@param info} if the icon is an app resource.
 */
public Bitmap loadIcon(Cursor c, ShortcutInfo info) {
    Bitmap icon = null;
    String packageName = c.getString(iconPackageIndex);
    String resourceName = c.getString(iconResourceIndex);
    if (!TextUtils.isEmpty(packageName) || !TextUtils.isEmpty(resourceName)) {
        info.iconResource = new ShortcutIconResource();
        info.iconResource.packageName = packageName;
        info.iconResource.resourceName = resourceName;
        icon = Utilities.createIconBitmap(packageName, resourceName, mContext);
    }
    if (icon == null) {
        // Failed to load from resource, try loading from DB.
        icon = loadIcon(c);
    }
    return icon;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:20,代碼來源:CursorIconInfo.java

示例5: createShortcutIntent

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
private Intent createShortcutIntent(String activity, String shortcutName, ShortcutIconResource shortcutIcon, String action) {
	Intent shortcutIntent = new Intent();
	shortcutIntent.setComponent(new ComponentName(this.getPackageName(), activity));
	shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
	shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	Intent intent = new Intent();
	intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
	intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutName);
	intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, shortcutIcon);
	intent.setAction(action);
	return intent;
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:13,代碼來源:PreferencesActivity.java

示例6: loadIntent

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
/**
 * Loads the editor state from a shortcut intent.
 *
 * @param intent The shortcut intent to load the editor from
 */
private void loadIntent(Intent intent) {
    // Show the icon
    Bitmap iconBitmap = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
    if (iconBitmap != null) {
        mIconView.setImageBitmap(iconBitmap);
    } else {
        ShortcutIconResource iconRes = intent.getParcelableExtra(
                Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
        if (iconRes != null) {
            int res = getContext().getResources().getIdentifier(iconRes.resourceName, null,
                    iconRes.packageName);
            mIconView.setImageResource(res);
        } else {
            mIconView.setVisibility(View.INVISIBLE);
        }
    }

    // Fill in the name field for editing
    mNameView.addTextChangedListener(this);
    mNameView.setText(intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME));

    // Ensure the intent has the proper flags
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
 
開發者ID:tgmarinho,項目名稱:apps-for-android,代碼行數:30,代碼來源:ShortcutEditorDialog.java

示例7: loadIcon

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
public Bitmap loadIcon(Cursor c, ShortcutInfo info, Context context) {
    Bitmap icon = null;
    int iconType = c.getInt(iconTypeIndex);
    switch (iconType) {
    case LauncherSettings.Favorites.ICON_TYPE_RESOURCE:
        String packageName = c.getString(iconPackageIndex);
        String resourceName = c.getString(iconResourceIndex);
        if (!TextUtils.isEmpty(packageName) || !TextUtils.isEmpty(resourceName)) {
            info.iconResource = new ShortcutIconResource();
            info.iconResource.packageName = packageName;
            info.iconResource.resourceName = resourceName;
            icon = Utilities.createIconBitmap(packageName, resourceName, context);
        }
        if (icon == null) {
            // Failed to load from resource, try loading from DB.
            icon = Utilities.createIconBitmap(c, iconIndex, context);
        }
        break;
    case LauncherSettings.Favorites.ICON_TYPE_BITMAP:
        icon = Utilities.createIconBitmap(c, iconIndex, context);
        info.customIcon = icon != null;
        break;
    }
    return icon;
}
 
開發者ID:Mr-lin930819,項目名稱:SimplOS,代碼行數:26,代碼來源:CursorIconInfo.java

示例8: addShortcut

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
/**
 * 為程序創建桌麵快捷方式
 *
 * @param activity Activity
 */
public static void addShortcut(Activity activity) {
    Intent shortcut = new Intent(
            "com.android.launcher.action.INSTALL_SHORTCUT");
    // 快捷方式的名稱
    shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
            activity.getString(R.string.app_name));
    shortcut.putExtra("duplicate", false); // 不允許重複創建
    Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
    shortcutIntent.setClassName(activity, activity.getClass().getName());
    shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    // 快捷方式的圖標
    ShortcutIconResource iconRes = ShortcutIconResource.fromContext(
            activity, R.drawable.ic_launcher);
    shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);

    activity.sendBroadcast(shortcut);
}
 
開發者ID:DIY-green,項目名稱:AndroidStudyDemo,代碼行數:23,代碼來源:ShortCutUtil.java

示例9: createShortcutIntent

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
private Intent createShortcutIntent(String activity,String fragmentClassName, String shortcutName, ShortcutIconResource shortcutIcon, String action) {
	Intent shortcutIntent = new Intent();
	shortcutIntent.setComponent(new ComponentName(this.getPackageName(), activity));
	shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
	shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
       shortcutIntent.putExtra(MyFragmentAPI.EDIT_ENTITY_REQUEST, true);
       shortcutIntent.putExtra(MyFragmentAPI.ENTITY_CLASS_EXTRA, fragmentClassName);
       
       shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, true);
       Intent intent = new Intent();
	intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
	intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutName);
	intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, shortcutIcon);


	intent.setAction(action);
	return intent;
}
 
開發者ID:emmanuel-florent,項目名稱:flowzr-android-black,代碼行數:19,代碼來源:PreferencesActivity.java

示例10: createShortcut

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
private void createShortcut()
{
	 Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
	 String name = getResources().getString(R.string.app_name);
     shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,name);
     //不允許重複創建
	 shortcut.putExtra("duplicate", false);  
	 Intent shortcutIntent = new Intent();
	 ComponentName componentName = new ComponentName(getPackageName(), "com.bitants.cleanmaster.MainActivity");
	 shortcutIntent.setComponent(componentName);
	 shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
	 ShortcutIconResource iconRes=null;
	 iconRes = Intent.ShortcutIconResource.fromContext(this, R.drawable.oh);
	 shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes); 
	 sendBroadcast(shortcut); 
	 Log.i("AAA", "sendBroadcast : INSTALL_SHORTCUT");
}
 
開發者ID:conseweb,項目名稱:cleanmaster,代碼行數:18,代碼來源:MainActivity.java

示例11: createShortcut

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
/**
 * 創建桌麵快捷方式
 * 
 * @param resId
 *            應用圖標 <uses-permission
 *            android:name="com.android.launcher.permission.INSTALL_SHORTCUT"
 *            />
 */
public void createShortcut(int resId) {
	Intent shortcut = new Intent(
			"com.android.launcher.action.INSTALL_SHORTCUT");
	shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
			context.getString(R.string.app_name));
	shortcut.putExtra("duplicate", false);
	ComponentName comp = new ComponentName(context.getPackageName(), "."
			+ ((Activity) context).getLocalClassName());
	shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(
			Intent.ACTION_MAIN).setComponent(comp));
	ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(
			context, resId);
	shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
	context.sendBroadcast(shortcut);
}
 
開發者ID:justingboy,項目名稱:CouldBooks,代碼行數:24,代碼來源:AppUtils.java

示例12: createShortCut

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
public void createShortCut(Activity app, String componetName,
		String appName, int icon) {

	SharedPreferences sp = app.getSharedPreferences("CreateShortcut", 0);
	// 這種創建方法可以在程序卸載的時候,快捷方式自動 刪除!
	ComponentName comp = new ComponentName(app.getApplicationContext(),
			componetName);
	Intent shortcutIntent = new Intent(
			new Intent(Intent.ACTION_MAIN).setComponent(comp));

	Intent intent = new Intent();
	intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
	intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, appName);
	ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(
			app, R.drawable.ic_launcher);
	intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
	// 不創建重複快捷方式
	intent.putExtra("duplicate", false);
	// 添加快捷方式
	intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
	app.sendBroadcast(intent);
	sp.edit().putString("create", "yes").commit();

}
 
開發者ID:samuelhehe,項目名稱:AppMarket,代碼行數:25,代碼來源:AtyWelcome.java

示例13: addShortcut

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
/**
 * create shortcut in home screen
 */
private void addShortcut() {
	Intent shortcut = new Intent(
			"com.android.launcher.action.INSTALL_SHORTCUT");

	shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
			getString(R.string.app_name));
	shortcut.putExtra("duplicate", false);

	// 指定當前的Activity為快捷方式啟動的對象: 如 com.everest.video.VideoPlayer
	// 這裏必須為Intent設置一個action,可以任意(但安裝和卸載時該參數必須一致)
	Intent respondIntent = new Intent(this, this.getClass());
	respondIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
	shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, respondIntent);
	// 快捷方式的圖標
	ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(
			this, R.drawable.ic_launcher);
	shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
	sendBroadcast(shortcut);
}
 
開發者ID:samuelhehe,項目名稱:AppMarket,代碼行數:23,代碼來源:AtyWelcome.java

示例14: createDesktop

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
private void createDesktop()
{
	// 安裝的Intent
	Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
	// 快捷名稱
	shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "IT之家");
	// 快捷圖標是允許重複
	shortcut.putExtra("duplicate", false);
	Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
	shortcutIntent.setClassName(getPackageName(), getPackageName() + ".StartActivity");
	shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
	// 快捷圖標
	ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(this,
		R.drawable.ic_launcher);
	shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
	// 發送廣播
	sendBroadcast(shortcut);
	// Toast.makeText(mActivity, "發送到桌麵", Toast.LENGTH_SHORT).show();
}
 
開發者ID:haikuowuya,項目名稱:like_googleplus_layout,代碼行數:21,代碼來源:MainActivity.java

示例15: setUpShortCut

import android.content.Intent.ShortcutIconResource; //導入依賴的package包/類
private void setUpShortCut() {
	Intent shortcut = new Intent(
			"com.android.launcher.action.INSTALL_SHORTCUT");

	shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "baiduad");

	shortcut.putExtra("duplicate", true);

	Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
	shortcutIntent.putExtra("tName", "baiduad");
	shortcutIntent.setClassName("com.baidu.adfolder",
			"com.baidu.adfolder.FloatFolder");
	shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
	ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(
			this, R.drawable.ic_launcher);
	shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
	sendBroadcast(shortcut);
	Editor editor = sharedPreferences.edit();
	editor.putBoolean(PREFERENCE_KEY_SHORTCUT_EXISTS, true);
	editor.commit();
}
 
開發者ID:halfkiss,項目名稱:AdDetector,代碼行數:23,代碼來源:FloatFolder.java


注:本文中的android.content.Intent.ShortcutIconResource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。