Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create a shortcut which only Toast something when I touched it
    text
    copied!<p>I want to create a shortcut in Android, and when I touch it, it will only do something silently such as <code>Toast</code> something. But I found that it will display the main <code>Activity</code>. How could I get it to run silently?</p> <p>Just like the <em>AdvancedTaskManager</em>'s shortcut~Click and then <code>Toast</code>.</p> <p>Thanks.</p> <p>At the moment, I've got:</p> <pre><code>public class ShortcutOnclickActivity extends Activity { private static final String tag = ShortcutOnclickActivity.class .getSimpleName(); public static final String ACTION_SHORTCUT_CLICKED = ShortcutOnclickActivity.class.getName(); @Override protected void onCreate(Bundle savedInstanceState) { Toast.makeText(this, "Clicked", Toast.LENGTH_SHORT).show(); Log.d(tag, "Clicked!"); finish(); super.onCreate(savedInstanceState); return; } } &lt;!-- Shortcut --&gt; &lt;activity android:name=".ShortcutActivity" android:screenOrientation="portrait"&gt; &lt;/activity&gt; &lt;activity-alias android:name="CreateShortcutActivity" android:targetActivity=".ShortcutActivity"&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;/category&gt; &lt;/intent-filter&gt; &lt;/activity-alias&gt; &lt;activity android:name=".ShortcutOnclickActivity" android:screenOrientation="portrait"&gt; &lt;intent-filter&gt; &lt;action android:name="com.androidesk.ShortcutOnclickActivity" /&gt; &lt;category android:name="android.intent.category.DEFAULT"&gt; &lt;/category&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre>
 

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