Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 7.1.1-检查是否使用了快捷方式_Android_Android Intent_Android 7.1 Nougat_Android Appshortcut - Fatal编程技术网

Android 7.1.1-检查是否使用了快捷方式

Android 7.1.1-检查是否使用了快捷方式,android,android-intent,android-7.1-nougat,android-appshortcut,Android,Android Intent,Android 7.1 Nougat,Android Appshortcut,因此,基本上我想要实现的是:了解我何时通过快捷方式访问活动,何时不通过。我使用的是静态快捷方式 检查了文档,但没有发现任何问题。也许这与我的意图有关,这是我还没有掌握的Android编程的一部分 谢谢。使用应用程序快捷方式特有的操作字符串。请注意,对于清单中的,操作字符串不需要在上-请注意,根本不需要 无论如何,应用程序快捷方式的元素中必须有android:action属性(出于无法解释的原因)。因此,将其设置为某个字符串。然后,在活动中,可以使用getIntent()查看用于创建活动的Inte

因此,基本上我想要实现的是:了解我何时通过快捷方式访问活动,何时不通过。我使用的是静态快捷方式

检查了文档,但没有发现任何问题。也许这与我的意图有关,这是我还没有掌握的Android编程的一部分


谢谢。

使用应用程序快捷方式特有的操作字符串。请注意,对于清单中的
操作字符串不需要在
上-请注意,
根本不需要


无论如何,应用程序快捷方式的
元素中必须有
android:action
属性(出于无法解释的原因)。因此,将其设置为某个字符串。然后,在活动中,可以使用
getIntent()
查看用于创建活动的
Intent
,并查看它是否具有此特定操作字符串。如果有,那么活动是通过应用程序快捷方式创建的。

官方文档应该给你一些提示,尽管它不能直接回答你的问题。

另一种简单的方法是,在处理动态快捷方式时,可以向意图添加某种标志,并在目标活动中检查该标志,然后可以确保该活动是从快捷方式调用的


希望它有帮助…

您可以将此添加到android:action=“android.intent.action.VIEW”intent每个快捷方式:

<intent
   <extra
         android:name="key"
         android:value="value" />
</intent>
Intent intentaction = getIntent();


if (intentaction.hasExtra("key")) {

        //Do something 
    }