- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试通过服务为我的应用程序创建快捷方式。以下代码适用于 SDK <= 21
, 但它在 SDK = 23
上无法正常工作
快捷方式的创建是这样完成的:
Intent shortcutIntent = new Intent(this, MainActivity.class);
shortcutIntent.putExtra(EXTRA_SHORTCUT_CLICKED, true); //This is only to check when the user clicked on the created shortcut
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
Intent addIntent = new Intent();
addIntent.putExtra("duplicate", false);
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "TEST");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.application_icon));
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
sendBroadcast(addIntent);
在SDK <= 21
快捷方式已创建,如果已经存在,则不会创建其他实例。
在SDK = 23
如果我按下创建的快捷方式并尝试再次创建快捷方式,或者如果我重新启动设备然后再次尝试创建快捷方式,则快捷方式只会被复制。
我尝试先卸载快捷方式,但在 SDK 23
上没有成功,如下:
Intent shortcutIntent = new Intent(this, MainActivity.class);
shortcutIntent.putExtra(EXTRA_SHORTCUT_CLICKED, true); //This is only to check when the user clicked on the created shortcut
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
Intent addIntent = new Intent();
addIntent.putExtra("duplicate", false);
addIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "TEST");
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.application_icon));
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
sendBroadcast(addIntent);
这是服务实现:
public class MyService extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
createShortcut(); //This is where I create the shortcut
return super.onStartCommand(intent,flags,startId);
}
}
Android 6 是否改变了快捷方式创建策略?我在文档中找不到任何内容。
[更新] 我试图通过单击示例应用程序上的按钮来创建快捷方式,但这种情况仍然发生。单击创建的快捷方式后,快捷方式将重复,然后尝试再次创建它。重启设备会发生同样的事情。
[UPDATE2] 我正在查看 Launcher3 谷歌应用程序的 grep 代码,我发现快捷方式安装调用了 registerSessionCallback这取决于调用线程。可能是关于这些新变化的问题?
最佳答案
对于遇到同样问题的人:
Google 取消了对 Launcher3 上的卸载快捷方式的支持,Google 现在在 Android M 上支持 Launcher。
此外,快捷方式重复是最新 Android M 版本 (MRA58K) 上的一个问题,现在由开发团队处理。
你们可以在这里关注这个问题,https://code.google.com/p/android/issues/detail?id=179697
[更新] Google 刚刚修复了这个问题,它将在下一个版本中发布。
关于Android M 快捷安装/卸载重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33036774/
1.使用start-all.sh启动hadoop服务时,提示输入 您确定要继续连接吗(是/否) 当我通过脚本启动它时如何抑制这个提示,现在我正在使用期望模块,但我认为可能有一种更简单的方法来做到这一点
我安装了在 Ubuntu 12.04 下运行的 Geonode R 2.01。我尝试使用以下命令卸载它: sudo apt-get remove --purge geonode sudo apt-ge
假设我有 AppDomainA,它启动 AppDomainB。 AppDomainB 然后启动 AppDomainC。 如果在 AppDomainA 中卸载 AppDomainB,AppDomainC
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 8年前关闭。 Improve this q
我尝试使用以下命令从我的 Ubuntu 中卸载 NGinX: sudo apt-get remove nginx-core nginx-full nginx-light nginx-extras n
我已经从 /Applications/ 中删除了 MacVim目录,但当我输入 vim 时在终端中显示错误:no such file or directory: /Applications/MacVi
我的页面中有一个 iframe,该 iframe 嵌入了一个不在我的服务器上的网站。 我正在寻找一种在 iframe 重定向之前触发函数的方法。例如,当用户单击 iframe 内的链接并且 ifram
看来我被 Visual Studio 的 Atomineer Pro 文档加载项挟持了!试用期结束了,我没有用了!但现在每次我在 Visual Studio 中做某事时,我都会收到一条错误消息并发送到
我有一个使用 WiX 完成的安装程序。安装完成后,它会启动一个应用程序,在 Explorer 进程中注入(inject)一些代码。 目前,当我卸载时,重新启动管理器会启动并关闭我的应用程序和资源管理器
在我的网络应用中,我需要在用户离开页面之前发送他们更改的最新数据。 我在页面卸载时调用这样的函数: window.onbeforeunload=sendData; 这就是函数内部调用的内容 funct
我使用 jQuery 和 history.js 来管理部分页面之间的动态转换;这样我就可以避免重新加载整个文档。其中一些部分页面调用自己独特的 javascript 文件。虽然页面之间的转换运行良好,
我需要处理应用程序包的变化,我这样写我的 mainfest mainfest.xml 我的接收器类
我目前在使用大量内存方面遇到了麻烦,我正在尽一切努力削减和优化涉及内存的代码...目前我的游戏的大部分 Nib 文件都加载了所有它在 ViewDidLoad 中的变量,现在我的问题是,在我的 view
如何从系统中删除 composer Php Dependecny Manager? 它说卸载无法继续,因为以下应用程序正在使用需要删除的文件。 Windows 资源管理器 最佳答案 我遇到了同样的问题
所以我使用 stow 在服务器上安装了 Python 2.7.1 源代码 .我过去很粗心,在处理源代码安装时我试图保持井井有条。所以,输入 stow。现在我使用 wget 安装了 easy_insta
有谁知道如何卸载 MacRuby?我在使用 RubyCocoa 然后决定试用 MacRuby,在安装 MacRuby 之后,RubyCocoa 已经停止工作。所以我想删除 MacRuby,但我找不到任
我无法从 64 位 EC2 卸载 mongo。在/usr/bin 我有 mongo 和 mongod 等等。当我从任何地方键入 mongo 时,它会在 1.8 版打开 shell。我现在下载了 2.0
本文实例讲述了Android编程实现监控apk安装,卸载,替换的方法。分享给大家供大家参考,具体如下: ?
1说明 mysql++是mysql开发团队为OO编程提供的C++开发库,是对mysql提供的底层数据存取API进行的C++封装,用其手册上的说法是:复杂而又庞大,当然功能也更强大。 Mysql+
自从我开始建立我的网站那天起,我安装了很多包,有时是为了测试一堆代码,有时是为了项目本身(后来我发现这不是需要的包)。但是现在,当我运行 pip freeze 时,我有一个包列表,我很难卸载不使用的包
我是一名优秀的程序员,十分优秀!