我想在安装时在home screen
上创建应用程序的快捷方式。安装时无法在主屏幕上创建应用程序的快捷方式安卓android
我的AndroidManifest.xml
<activity
android:name="com.example.test.ShortCutActivity"
android:icon="@drawable/ic_launcher"
android:label="@string/title_activity_short_cut" >
<intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
将此添加到我也有我的项目,ShortCutActivity名称创建一个Actvity。
ShortCutActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ShortcutIconResource icon =
Intent.ShortcutIconResource.fromContext(this, R.drawable.ic_launcher);
Intent intent = new Intent();
Intent launchIntent = new Intent(this,MainActivity.class);
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launchIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "ShortCut");
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
setResult(RESULT_OK, intent);
}
但它不产生任何快捷方式。我错过了什么吗?
这将只在我启动应用程序时起作用,我希望创建快捷方式当安装应用程序时 –
实际上这个选项在谷歌市场的开发人员配置文件中提供,设置选项 –
我们只能在第一次启动活动后以编程方式创建快捷方式 –