Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating shortcuts in Android via Intent
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/6337431/android-create-shortcuts-on-the-home-screen">Android create shortcuts on the home screen</a> </p> </blockquote> <p>I am having one <code>TextView</code> and <code>Button</code> in my Activity (HomeActivity.class).</p> <p><strong>Goal</strong>: When I click on the <code>Button</code> it should create a shortcut with the default android image as icon and text as entered in the <code>TextView</code>.</p> <p>So far I've found out that we can create shortcuts using <a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_CREATE_SHORTCUT" rel="nofollow noreferrer"><code>ACTION_CREATE_SHORTCUT</code></a></p> <p>This is the code I have so far:</p> <pre><code>Intent result = new Intent(android.content.Intent.ACTION_CREATE_SHORTCUT); result.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(getApplicationContext(), Editor.class)); result.putExtra(TodoDbAdapter.KEY_ROWID,rowid); result.putExtra(Intent.EXTRA_SHORTCUT_NAME,textView.getText()); result.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(HomeActivity.this, R.drawable.icon)); setResult(RESULT_OK, result); </code></pre> <p>My Manifest File :</p> <pre><code>&lt;activity android:name=".HomeActivity" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.CREATE_SHORTCUT" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre> <p>But this code does not create any shortcut.</p> <p>How can I create shortcuts?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload