Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/byteszero/shortcutforandroid
shortcutForAndroid android创建快捷方式
https://github.com/byteszero/shortcutforandroid
Last synced: 4 days ago
JSON representation
shortcutForAndroid android创建快捷方式
- Host: GitHub
- URL: https://github.com/byteszero/shortcutforandroid
- Owner: BytesZero
- License: apache-2.0
- Created: 2015-04-16T09:26:52.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-04-17T02:19:57.000Z (over 9 years ago)
- Last Synced: 2023-11-05T13:22:25.906Z (about 1 year ago)
- Language: Java
- Size: 234 KB
- Stars: 5
- Watchers: 0
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# shortcutForAndroid
shortcutForAndroid android创建快捷方式
###主要代码如下
```java
/**
* 创建快捷方式
*/
private void createShortCut() {
// 创建快捷方式的Intent
Intent shortcutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
// 不允许重复创建
shortcutIntent.putExtra("duplicate", false);
// 快捷方式的名字
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,shortcut_name);
// 快捷方式icon
Parcelable icon = Intent.ShortcutIconResource.fromContext(
MainActivity.this, R.mipmap.shortcut);
//设置icon
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
// 点击快捷图片,运行的程序主入口
Intent intent = new Intent(MainActivity.this,
MainActivity.class);shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
// 发送广播,创建快捷方式
sendBroadcast(shortcutIntent);Toast.makeText(MainActivity.this,"快捷方式创建",Toast.LENGTH_SHORT).show();
}
```