Creating shortcut problems


  1. xmiasma

    xmiasma Member

    I have found a bunch of resources online about how to create and shortcut on the home screen but for the life of me i cant get any of them to work. Heres a snippet of what im doing to create my shortcut

    Code (Text):
    1. Intent i = new Intent();
    2.         i.setClassName(this, this.getClass().getName());
    3.        
    4.         i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    5.         i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    6.        
    7.         Intent intent = new Intent();
    8.         intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, i);
    9.         intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "eXorg");
    10.         intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
    11.         intent.setAction(Intent.ACTION_CREATE_SHORTCUT);
    12.         this.sendBroadcast(intent);
    13.         setResult(RESULT_OK, intent);
    14.  
    and the manifest

    Code (Text):
    1.  <activity android:name=".MainActivity"
    2.                   android:label="@string/app_name">
    3.             <intent-filter>
    4.                 <action android:name="android.intent.action.MAIN" />
    5.                 <category android:name="android.intent.category.LAUNCHER" />
    6.             </intent-filter>
    7.             <intent-filter>
    8.                 <action android:name="android.intent.action.CREATE_SHORTCUT" />
    9.                 <category android:name="android.intent.category.DEFAULT" />
    10.             </intent-filter>
    11.         </activity>
    12.        
    13.  
    14.     </application>
    15.    
    16.     <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
    17.      *** ^^^ not sure if this is needed or is even in the right spot ******
    18.  
    19.  
    Any help would be awesome. thanks guys.

    Advertisement
    :
  2. xmiasma

    xmiasma Member

    seriously no one has any idea on what to do? :( theres been like 55 ppl that viewed this thread.
  3. fourplay56

    fourplay56 New Member

    What you need is:

    intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
Loading...

Share This Page