我是按照官方文件做的快捷键显示在发射器上。当我开始测试时,我会得到这个错误。我怎么才能修好它?我做错什么了?
Error:(6, 23) No resource found that matches the given name (at 'icon' with value '@drawable/compose_icon').
Error:(8, 36) No resource found that matches the given name (at 'shortcutLongLabel' with value '@string/comp
安装应用程序时,我使用以下代码创建快捷方式:
在AndroidManifest.xml中:
<!-- for creating a shortcut in the home screen -->
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
在主活动的onCreate()中:
// an Intent to create a shortCut
Intent shortcutIntent = new Intent("co
我正在开发一个简单的应用程序,它有一个按钮,可以在启动器上创建我的应用程序主要活动的快捷方式。 我遵循了以下主题:How can I add my application's shortcut to the homescreen upon app installation? 但是,当我单击该按钮并执行"createShortcut“函数时,没有创建任何快捷方式。我正在使用android Oreo和on以及运行Android 8.1的Pixel2模拟器在Galaxy S7上测试我的应用程序。 我希望你能帮我解决这个问题。这是主要的活动: package com.example.
我正在制作一个应用程序,它为我的另一个应用程序制作主屏幕快捷方式,如果用户已经安装了它。
它部分起作用。在API级别小于23的情况下,它工作得非常完美。在Android6上,它创建了快捷方式,但绕过了Intent.EXTRA_SHORTCUT_NAME和Intent.EXTRA_SHORTCUT_ICON_RESOURCE,留下了我不想使用的原始图标和名称。
下面是我使用的代码示例:
ApplicationInfo selectedApp; //app that should be used for shortcut
Intent shortcutIntent = new Intent(get
这是一个创建直接快捷方式的代码示例,它调用特定的号码,并在Android M和更低版本上工作。
public void installShortcutGetId(){
Intent intent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,"MyCallShortcut");
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new
可能重复:
我的活动中有一个TextView和Button (HomeActivity.class)。
目标:当我单击Button时,它应该创建一个快捷方式,将默认的Button图像作为图标,并创建TextView中输入的文本。
到目前为止,我发现我们可以使用创建快捷方式
这是我到目前为止掌握的代码:
Intent result = new Intent(android.content.Intent.ACTION_CREATE_SHORTCUT);
result.putExtra(Intent.EXTRA_SHORTCUT_INTENT,
new Inte
ActivityMain是singleTask。
我可以使用代码A在屏幕上创建动态快捷方式图标,当我单击快捷方式图标时,它将显示ActivityMain。
你知道,我也可以通过点击应用图标来显示ActivityMain。
当我使用singleTask时,我如何才能知道动态快捷方式中的活动?
顺便说一句,B码不起作用。
码A
@TargetApi(25)
private fun createShorcut() {
val sM = getSystemService(ShortcutManager::class.java)
val intent1 = In