• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Creating shortcut problems

xmiasma

Newbie
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:
Intent i = new Intent();
        i.setClassName(this, this.getClass().getName());
        
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        
        Intent intent = new Intent();
        intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, i);
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "eXorg");
        intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
        intent.setAction(Intent.ACTION_CREATE_SHORTCUT);
        this.sendBroadcast(intent);
        setResult(RESULT_OK, intent);

and the manifest

Code:
 <activity android:name=".MainActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
      			<action android:name="android.intent.action.CREATE_SHORTCUT" />
      			<category android:name="android.intent.category.DEFAULT" />
    		</intent-filter>
        </activity>
        

    </application>
    
    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
     *** ^^^ not sure if this is needed or is even in the right spot ******

Any help would be awesome. thanks guys.
 
Back
Top Bottom