@Override
public void setShortcut(String did, String manufacturer, String deviceName) {
//Home screen shortcut for favourite device
if (Build.VERSION.SDK_INT < 25)
return;
ShortcutManager sM = getSystemService(ShortcutManager.class);
sM.removeAllDynamicShortcuts();
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra(Constants.EXTRA_DEVICE_ID, did);
ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "shortcut1")
.setIntent(intent)
.setLongLabel(manufacturer + " " + deviceName)
.setShortLabel(deviceName)
.setIcon(Icon.createWithResource(this, R.drawable.ic_device_placeholder))
.build();
sM.setDynamicShortcuts(Collections.singletonList(shortcut));
}
MainActivity.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:AndroidFileHost_Browser
作者:
评论列表
文章目录