Hello all,
I am trying to create a desktop shortcut to one of my Activity in Android. I use the code that work in every tuto example i have read:
final Intent shortcutIntent = new Intent(Intent.ACTION_MAIN);
ComponentName name = new ComponentName(getPackageName(), ".MyActivity");
shortcutIntent.setComponent(name);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
final Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "blabla");
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon);
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
sendBroadcast(intent);
finish();
And I added the MAIN action to my activity:
<activity android:label="@string/app_name" android:name=".MyActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
The result is that the application does not want to launch!
In the Logcat everything seem fine:
10-01 01:17:51.591: INFO/ActivityManager(2424): Starting activity: Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=my.package.name/.MyActivity bnds=[125,384][235,522] (has extras) }
And the Home tell me that the application is not Installed.
Please help me, I am totally lost and spend a few hours trying to solve the issue and read all info I can get.
Thank a lot!