如何在屏幕肌酸的应用程序图标时prevent敬酒消息 [英] How to prevent toast message when creatin app icon on screen

查看:277
本文介绍了如何在屏幕肌酸的应用程序图标时prevent敬酒消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建的 APPP图标手机屏幕上,我这样做,但是当我这样做的 automaticli应用程序创建敬酒消息,如何prevent此敬酒消息肌酸应用程序图标时,或在屏幕上删除图标?
谢谢你。

这就是我要做的事code

 私人无效addShortcut(){
意图shortcutIntent =新意图(com.android.launcher.action.INSTALL_SHORTCUT);//快捷方式名称
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,的getString(R.string.app_name));
shortcutIntent.putExtra(重复,FALSE);组件名排版=新单元名(this.getPackageName(),+ this.getLocalClassName()。);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT,新的意图(Intent.ACTION_MAIN).setComponent(COMP));//快捷方式图标
ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(这一点,R.drawable.icon);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,iconRes);sendBroadcast(shortcutIntent);
}
私人无效delShortcut(){
意图快捷=新意图(com.android.launcher.action.UNINSTALL_SHORTCUT);//快捷方式名称
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,的getString(R.string.app_name));串appClass = this.getPackageName()+。 + this.getLocalClassName();
组件名补偿=新的组件名(this.getPackageName(),appClass);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,新的意图(Intent.ACTION_MAIN).setComponent(COMP));sendBroadcast(快捷方式);
}
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.main);
delShortcut();
addShortcut();

添加快捷键的权限

 <使用许可权的android:NAME =com.android.launcher.permission.INSTALL_SHORTCUT>< /使用许可权>
<使用许可权的android:NAME =com.android.launcher.permission.UNINSTALL_SHORTCUT/>


解决方案

创建隐藏的属性(我创建复选框),之后创建快捷方式设置这个事实,然后检查参数:

 私人无效checkShortcut(){
        。快捷= GlobalClass preFS.getBoolean(快捷方式,FALSE);
        如果(快捷键==真){
            // addShortcut();
        }
        其他{
            remShortcut();
        }    }

I want to create appp icon on phone screen and i do it but when i do it automaticli app creates toast message, How to prevent this toast message when creatin app icon or deleting icon on screen? Thanks.

That is code of how i do it

private void addShortcut(){
Intent shortcutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");

// Shortcut name
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
shortcutIntent.putExtra("duplicate", false);

ComponentName comp = new ComponentName(this.getPackageName(), "."+this.getLocalClassName());
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(comp));

// Shortcut icon
ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);

sendBroadcast(shortcutIntent);
}


private void delShortcut(){
Intent shortcut = new Intent("com.android.launcher.action.UNINSTALL_SHORTCUT");

// Shortcut adı
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));

String appClass = this.getPackageName() + "." +this.getLocalClassName();
ComponentName comp = new ComponentName(this.getPackageName(), appClass);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(comp));

sendBroadcast(shortcut);
}


public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
delShortcut();
addShortcut();

Permissions for adding shortcuts

<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"></uses-permission>
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />

解决方案

Create hidden properties (i create CheckBox), after create shortcut set this true, then check parameter:

private void checkShortcut() {
        shortCut = GlobalClass.PREFS.getBoolean("ShortCut", false);
        if (shortCut == true) {
            //addShortcut();
        }
        else{
            remShortcut();
        }

    }

这篇关于如何在屏幕肌酸的应用程序图标时prevent敬酒消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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