android 创建快捷方式
shortactivity类
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
if (getIntent().getAction().equals(Intent.ACTION_CREATE_SHORTCUT))
{
Intent _int=new Intent();
_int.putExtra(Intent.EXTRA_SHORTCUT_NAME, "myshortcut");
_int.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(this,R.drawable.ic_launcher));
_int.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(this,MyshortcutActivity.class));
setResult(RESULT_OK, _int);
finish();
}
}
androidmainfest.xml 文件添加activity
<activity android:name=".shortactivity" >
<intent-filter >
<action android:name="android.intent.action.CREATE_SHORTCUT" />
</intent-filter>
</activity>
</application>