Java Code Examples for android.content.Intent.ShortcutIconResource#fromContext()

The following examples show how to use android.content.Intent.ShortcutIconResource#fromContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShortCutUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 为程序创建桌面快捷方式
 *
 * @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);
}
 
Example 2
Source File: a.java    From letv with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 3
Source File: VolumePanelShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_volume_panel);
}
 
Example 4
Source File: ShowPowerMenuShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_power_menu);
}
 
Example 5
Source File: SwitchAppShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_previous_app);
}
 
Example 6
Source File: SleepShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_sleep);
}
 
Example 7
Source File: LauncherDrawerShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_launcher_drawer);
}
 
Example 8
Source File: RecentAppsShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_recent_apps);
}
 
Example 9
Source File: ScreenrecordShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_screenrecord);
}
 
Example 10
Source File: TorchShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_torch);
}
 
Example 11
Source File: GoogleNowShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_google_now);
}
 
Example 12
Source File: AMultiShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
public ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, mIconResId);
}
 
Example 13
Source File: KillAppShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_kill_app);
}
 
Example 14
Source File: GoHomeShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_home);
}
 
Example 15
Source File: UnlockShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.ic_lockscreen_unlock);
}
 
Example 16
Source File: ScreenshotShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_screenshot);
}
 
Example 17
Source File: AppLauncherShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_app_launcher);
}
 
Example 18
Source File: ClearNotificationsShortcut.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
protected ShortcutIconResource getIconResource() {
    return ShortcutIconResource.fromContext(mContext, R.drawable.shortcut_notif_clear);
}