{% else-1 %}
Нужны права
<uses-permission
android:name=\"com.android.launcher.permission.INSTALL_SHORTCUT\" /
>
<uses-permission
android:name=\"com.android.launcher.permission.UNINSTALL_SHORTCUT\" /
>

                        
public void addShortcut
(Context ctx, Class startClass) {
if (startClass==null || ctx ==
null) return;
// Adding shortcut on Home
screen
Intent shortcutIntent = new
Intent(ctx, startClass);
shortcutIntent.setAction
(Intent.ACTION_MAIN);
Intent addIntent = new
Intent();
addIntent.putExtra
("duplicate", false);
addIntent.putExtra
(Intent.EXTRA_SHORTCUT_INTENT,
shortcutIntent);
addIntent.putExtra
(Intent.EXTRA_SHORTCUT_NAME,
ctx.getString
(R.string.app_name));
addIntent.putExtra
(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext
(ctx, R.drawable.ic_launcher));
addIntent.setAction
("com.android.launcher.action.INSTALL_SHORTCUT");
ctx.sendBroadcast
(addIntent);
}
public void removeShortcut
(Context ctx, Class startClass) {
if (startClass==null || ctx ==
null) return;
// Deleting shortcut for
MainActivity on Home screen
Intent shortcutIntent = new
Intent(ctx, startClass);
shortcutIntent.setAction
(Intent.ACTION_MAIN);
Intent addIntent = new
Intent();
addIntent.putExtra
("duplicate", false);
addIntent.putExtra
(Intent.EXTRA_SHORTCUT_INTENT,
shortcutIntent);
addIntent.putExtra
(Intent.EXTRA_SHORTCUT_NAME,
ctx.getString
(R.string.app_name));
addIntent.putExtra
(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext
(ctx, R.drawable.ic_launcher));
addIntent.setAction
("com.android.launcher.action.UNINSTALL_SHORTCUT");
ctx.sendBroadcast
(addIntent);
}
0 18 0
0

Нет фото
System * [мошенник] 0.85
• 29 дек 2013, 16:55


Куда это пихать? ))