为快捷键设置不同的图标/图像? [英] set different icon/image for shortcut ?

查看:167
本文介绍了为快捷键设置不同的图标/图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个程序,它可以创造我在Android模拟器应用homescreen.But的问题是,当我创建的快捷方式,然后它有默认的A​​ndr​​oid图标的快捷方式。
我的问题是如何能更改快捷方式图标?

我用下面一行设置图标

 意图J =新意图();
j.putExtra(Intent.EXTRA_SHORTCUT_INTENT,I);
j.putExtra(Intent.EXTRA_SHORTCUT_NAME,N);
j.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,R.drawable.icon);
j.putExtra(重复,FALSE);
j.setAction(com.android.launcher.action.INSTALL_SHORTCUT);
sendBroadcast(J);


解决方案

您可以通过以下两种方式做到这一点。


  

putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,渣油);


  
  

putExtra(Intent.EXTRA_SHORTCUT_ICON,位图);


I have written a program that can create shortcut of my application in android emulator homescreen.But the problem is when i created the shortcut then it has the default android icon. My question is how can i change the icon of the shortcut ?

I have used the following line to set the icon

Intent j=new Intent();
j.putExtra(Intent.EXTRA_SHORTCUT_INTENT,i);     
j.putExtra(Intent.EXTRA_SHORTCUT_NAME,n);                                                   
j.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,R.drawable.icon);
j.putExtra ("duplicate", false);
j.setAction("com.android.launcher.action.INSTALL_SHORTCUT");   
sendBroadcast(j);

解决方案

You can do this in two way.

putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,resId);

putExtra(Intent.EXTRA_SHORTCUT_ICON, bitmap);

这篇关于为快捷键设置不同的图标/图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆