当前位置: 首页>>代码示例>>Java>>正文


Java Intent.ShortcutIconResource方法代码示例

本文整理汇总了Java中android.content.Intent.ShortcutIconResource方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.ShortcutIconResource方法的具体用法?Java Intent.ShortcutIconResource怎么用?Java Intent.ShortcutIconResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.ShortcutIconResource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createShortcutIntent

import android.content.Intent; //导入方法依赖的package包/类
public Intent createShortcutIntent(Context context, File file) {
    // create shortcut if requested
    Intent.ShortcutIconResource icon =
            Intent.ShortcutIconResource.fromContext(context, R.mipmap.ic_launcher);

    Intent intent = new Intent();

    Intent launchIntent = new Intent(context, SplashScreenActivity.class);
    launchIntent.putExtra(CompileManager.FILE_PATH, file.getPath());
    launchIntent.setAction("run_from_shortcut");

    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent);
    intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, file.getName());
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
    return intent;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:17,代码来源:FileManager.java

示例2: handleInstallShortcutIntent

import android.content.Intent; //导入方法依赖的package包/类
private Intent handleInstallShortcutIntent(Intent intent) {
    Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    if (shortcut != null) {
        ComponentName component = shortcut.resolveActivity(VirtualCore.getPM());
        if (component != null) {
            String pkg = component.getPackageName();
            Intent newShortcutIntent = new Intent();
            newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME);
            newShortcutIntent.addCategory(Intent.CATEGORY_DEFAULT);
            newShortcutIntent.putExtra("_VA_|_intent_", shortcut);
            newShortcutIntent.putExtra("_VA_|_uri_", shortcut.toUri(0));
            newShortcutIntent.putExtra("_VA_|_user_id_", VUserHandle.myUserId());
            intent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT);
            intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent);

            Intent.ShortcutIconResource icon = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
            if (icon != null && !TextUtils.equals(icon.packageName, getHostPkg())) {
                try {
                    Resources resources = VirtualCore.get().getResources(pkg);
                    if (resources != null) {
                        int resId = resources.getIdentifier(icon.resourceName, "drawable", pkg);
                        if (resId > 0) {
                            Drawable iconDrawable = resources.getDrawable(resId);
                            Bitmap newIcon = BitmapUtils.drawableToBitmap(iconDrawable);
                            if (newIcon != null) {
                                intent.removeExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
                                intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, newIcon);
                            }
                        }
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return intent;
}
 
开发者ID:codehz,项目名称:container,代码行数:39,代码来源:BroadcastIntent.java

示例3: iconRes

import android.content.Intent; //导入方法依赖的package包/类
public Shortcut iconRes(Intent.ShortcutIconResource icon) {
    if (mIcon != null) {
        throw new IllegalStateException("Cannot set both iconRes and icon");
    }
    mIconRes = icon;
    return this;
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:8,代码来源:Shortcut.java

示例4: createShortcutInfo

import android.content.Intent; //导入方法依赖的package包/类
private static ShortcutInfo createShortcutInfo(Intent data, LauncherAppState app) {
    Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
    Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);

    if (intent == null) {
        // If the intent is null, we can't construct a valid ShortcutInfo, so we return null
        return null;
    }

    final ShortcutInfo info = new ShortcutInfo();

    // Only support intents for current user for now. Intents sent from other
    // users wouldn't get here without intent forwarding anyway.
    info.user = Process.myUserHandle();

    if (bitmap instanceof Bitmap) {
        info.iconBitmap = LauncherIcons.createIconBitmap((Bitmap) bitmap, app.getContext());
    } else {
        Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
        if (extra instanceof Intent.ShortcutIconResource) {
            info.iconResource = (Intent.ShortcutIconResource) extra;
            info.iconBitmap = LauncherIcons.createIconBitmap(info.iconResource, app.getContext());
        }
    }
    if (info.iconBitmap == null) {
        info.iconBitmap = app.getIconCache().getDefaultIcon(info.user);
    }

    info.title = Utilities.trim(name);
    info.contentDescription = UserManagerCompat.getInstance(app.getContext())
            .getBadgedLabelForUser(info.title, info.user);
    info.intent = intent;
    return info;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:36,代码来源:InstallShortcutReceiver.java

示例5: Shortcut

import android.content.Intent; //导入方法依赖的package包/类
public Shortcut(Context ctx, Intent i, String name, Intent.ShortcutIconResource icon){
    super(name);
    this.packageName = icon.packageName;
    this.intent = i;
    try {
        Resources res = ctx.getPackageManager().getResourcesForApplication(icon.packageName);
        this.drawableIdent = res.getIdentifier(icon.resourceName, "drawable", icon.packageName);
        this.icon = res.getDrawable(drawableIdent);
    } catch (PackageManager.NameNotFoundException e) {
        this.icon = ctx.getResources().getDrawable(R.drawable.ic_launcher);

    }
}
 
开发者ID:jathak,项目名称:sflauncher,代码行数:14,代码来源:App.java

示例6: onSuccess

import android.content.Intent; //导入方法依赖的package包/类
private void onSuccess() {
    Intent.ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(this, getShortcutIcon());

    Intent intent = new Intent();

    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, getOpenShortcutActivityIntent());
    intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getShortcutName());
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);

    setResult(RESULT_OK, intent);
    finish();
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:13,代码来源:CreateShortcutActivity.java

示例7: onSuccess

import android.content.Intent; //导入方法依赖的package包/类
private void onSuccess() {
    Intent.ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher_round);

    Intent intent = new Intent();
    Intent launchIntent = new Intent(this, FloatingCodecOpenShortCutActivity.class);

    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent);
    intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);

    setResult(RESULT_OK, intent);
    finish();
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:14,代码来源:FloatingCodecCreateShortCutActivity.java

示例8: onSuccess

import android.content.Intent; //导入方法依赖的package包/类
private void onSuccess() {
    Intent.ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(this, R.mipmap.ic_launcher_round);

    Intent intent = new Intent();
    Intent launchIntent = new Intent(this, FloatingStylishOpenShortCutActivity.class);

    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent);
    intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);

    setResult(RESULT_OK, intent);
    finish();
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:14,代码来源:FloatingStylishCreateShortCutActivity.java

示例9: onSuccess

import android.content.Intent; //导入方法依赖的package包/类
private void onSuccess() {
    Intent.ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher_floating);

    Intent intent = new Intent();
    Intent launchIntent = new Intent(this, FloatingOpenShortCutActivity.class);

    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent);
    intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);

    setResult(RESULT_OK, intent);
    finish();
}
 
开发者ID:tranleduy2000,项目名称:floating_calc,代码行数:14,代码来源:FloatingCreateShortCutActivity.java

示例10: createShortcut

import android.content.Intent; //导入方法依赖的package包/类
/**
 * 创建桌面快捷方式
 *
 * @param resId 应用图标
 *              <uses-permission android:NAME="com.android.launcher.permission.INSTALL_SHORTCUT" />
 */
public static void createShortcut(Context context, int resId) {
    Intent shortcut = new Intent("com.android.launcher.doRoleAction.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));
    Intent.ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(context, resId);
    shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
    context.sendBroadcast(shortcut);
}
 
开发者ID:wzc25151,项目名称:lrs_android,代码行数:17,代码来源:AppUtil.java

示例11: onBookClicked

import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onBookClicked(long bookId) {
    if (action != null && action.equals(Intent.ACTION_CREATE_SHORTCUT)) {

        /* If this intent is used, shortcut's label will be overwritten (set to "Orgzly")
         * with some launchers (like Nova) on every app update.
         * It looks like it's due to setting action to ACTION_MAIN and category to
         * CATEGORY_LAUNCHER (which main activity uses)
         */
         // Intent launchIntent = Intent.makeRestartActivityTask(new ComponentName(this, MainActivity.class));

        Intent launchIntent = new Intent(this, MainActivity.class);
        launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        launchIntent.putExtra(AppIntent.EXTRA_BOOK_ID, bookId);

        Intent shortcut = new Intent(Intent.ACTION_CREATE_SHORTCUT);

        Shelf shelf = new Shelf(this);
        String title = BookUtils.getFragmentTitleForBook(shelf.getBook(bookId));
        if (title == null) {
            setResult(RESULT_CANCELED, shortcut);
            finish();
            return;
        }
        shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);

        Intent.ShortcutIconResource icon = Intent.ShortcutIconResource.fromContext(this, R.drawable.cic_orgzly_logo_with_notebook);
        shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);

        shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent);

        setResult(RESULT_OK, shortcut);
        finish();
    }
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:36,代码来源:BookChooserActivity.java

示例12: handleInstallShortcutIntent

import android.content.Intent; //导入方法依赖的package包/类
private Intent handleInstallShortcutIntent(Intent intent) {
    Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    if (shortcut != null) {
        ComponentName component = shortcut.resolveActivity(VirtualCore.getPM());
        if (component != null) {
            String pkg = component.getPackageName();
            Intent newShortcutIntent = new Intent();
            newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME);
            newShortcutIntent.addCategory(Intent.CATEGORY_DEFAULT);
            newShortcutIntent.putExtra("_VA_|_intent_", shortcut);
            newShortcutIntent.putExtra("_VA_|_uri_", shortcut.toUri(0));
            newShortcutIntent.putExtra("_VA_|_user_id_", VUserHandle.myUserId());
            intent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT);
            intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent);

            Intent.ShortcutIconResource icon = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
            if (icon != null && !TextUtils.equals(icon.packageName, getHostPkg())) {
                try {
                    Resources resources = VirtualCore.get().getResources(pkg);
                    int resId = resources.getIdentifier(icon.resourceName, "drawable", pkg);
                    if (resId > 0) {
                        //noinspection deprecation
                        Drawable iconDrawable = resources.getDrawable(resId);
                        Bitmap newIcon = BitmapUtils.drawableToBitmap(iconDrawable);
                        if (newIcon != null) {
                            intent.removeExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);
                            intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, newIcon);
                        }
                    }
                } catch (Throwable e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return intent;
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:38,代码来源:MethodProxies.java

示例13: addShortcut

import android.content.Intent; //导入方法依赖的package包/类
public static void addShortcut(Context c, String folder, String name) {
    Project p = new Project(folder, name);

    Intent.ShortcutIconResource icon;
    icon = Intent.ShortcutIconResource.fromContext(c, R.drawable.app_icon);

    try {
        Intent shortcutIntent = new Intent(c, AppRunnerActivity.class);
        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        shortcutIntent.putExtra(Project.NAME, p.getName());
        shortcutIntent.putExtra(Project.FOLDER, p.getFolder());

        Map<String, Object> map = AppRunnerHelper.readProjectProperties(c, p);

        final Intent putShortCutIntent = new Intent();
        putShortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
        putShortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, p.getName());
        putShortCutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
        putShortCutIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
        c.sendBroadcast(putShortCutIntent);
    } catch (Exception e) {
        // TODO
    }
    // Show toast
    Toast.makeText(c, "Adding shortcut for " + p.getName(), Toast.LENGTH_SHORT).show();

}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:29,代码来源:PhonkScriptHelper.java

示例14: getIconRes

import android.content.Intent; //导入方法依赖的package包/类
public Intent.ShortcutIconResource getIconRes() {
    return mIconRes;
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:4,代码来源:Shortcut.java

示例15: encodeToString

import android.content.Intent; //导入方法依赖的package包/类
String encodeToString() {
    try {
        if (activityInfo != null) {
            // If it a launcher target, we only need component name, and user to
            // recreate this.
            return new JSONStringer()
                .object()
                .key(LAUNCH_INTENT_KEY).value(launchIntent.toUri(0))
                .key(APP_SHORTCUT_TYPE_KEY).value(true)
                .key(USER_HANDLE_KEY).value(UserManagerCompat.getInstance(mContext)
                        .getSerialNumberForUser(user))
                .endObject().toString();
        } else if (shortcutInfo != null) {
            // If it a launcher target, we only need component name, and user to
            // recreate this.
            return new JSONStringer()
                    .object()
                    .key(LAUNCH_INTENT_KEY).value(launchIntent.toUri(0))
                    .key(DEEPSHORTCUT_TYPE_KEY).value(true)
                    .key(USER_HANDLE_KEY).value(UserManagerCompat.getInstance(mContext)
                            .getSerialNumberForUser(user))
                    .endObject().toString();
        } else if (providerInfo != null) {
            // If it a launcher target, we only need component name, and user to
            // recreate this.
            return new JSONStringer()
                    .object()
                    .key(LAUNCH_INTENT_KEY).value(launchIntent.toUri(0))
                    .key(APP_WIDGET_TYPE_KEY).value(true)
                    .key(USER_HANDLE_KEY).value(UserManagerCompat.getInstance(mContext)
                            .getSerialNumberForUser(user))
                    .endObject().toString();
        }

        if (launchIntent.getAction() == null) {
            launchIntent.setAction(Intent.ACTION_VIEW);
        } else if (launchIntent.getAction().equals(Intent.ACTION_MAIN) &&
                launchIntent.getCategories() != null &&
                launchIntent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) {
            launchIntent.addFlags(
                    Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        }

        // This name is only used for comparisons and notifications, so fall back to activity
        // name if not supplied
        String name = ensureValidName(mContext, launchIntent, label).toString();
        Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
        Intent.ShortcutIconResource iconResource =
            data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);

        // Only encode the parameters which are supported by the API.
        JSONStringer json = new JSONStringer()
            .object()
            .key(LAUNCH_INTENT_KEY).value(launchIntent.toUri(0))
            .key(NAME_KEY).value(name);
        if (icon != null) {
            byte[] iconByteArray = Utilities.flattenBitmap(icon);
            json = json.key(ICON_KEY).value(
                    Base64.encodeToString(
                            iconByteArray, 0, iconByteArray.length, Base64.DEFAULT));
        }
        if (iconResource != null) {
            json = json.key(ICON_RESOURCE_NAME_KEY).value(iconResource.resourceName);
            json = json.key(ICON_RESOURCE_PACKAGE_NAME_KEY)
                    .value(iconResource.packageName);
        }
        return json.endObject().toString();
    } catch (JSONException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:73,代码来源:InstallShortcutReceiver.java


注:本文中的android.content.Intent.ShortcutIconResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。