gpt4 book ai didi

java - 如何找到什么 'extras' 添加到与应用程序一起使用的 Intent ?

转载 作者:行者123 更新时间:2023-11-29 21:21:56 25 4
gpt4 key购买 nike

我正在开发的应用程序需要在可用的设备上利用其他应用程序的功能。

这是 Intents and Intent Filters 的范例应该在 Android 中处理。我将给出一个具体示例,说明对于所有情况,它在哪里失败(并且实际上没用)。

Example: Using an Intent to pass the content of an MMS to the messaging app:

  1. I go to the Intent class reference and find which system ACTION looks most appropriate (already am guessing - ACTION_SEND vs ACTION_SENDTO vs ACTION_VIEW and assuming that the ACTION is one declared by the system)
  2. I try and figure out if there is a specific Uri to supply for the data (there's this list for Google applications and I'm assuming this is then expected to be supplied by all apps and found individually?)
  3. I now want to find what EXTRA keys should be used to supply the data (message body text, image). I have no idea and no hints whatsoever?

当然,我可以查看 StackOverflow 并找到答案 herehere哪种给出了我正在寻找的答案(我还没有找到同时提供带有收件人 图像的彩信的任何答案)。但这实际上应该如何一般地完成呢?非系统、非通用、sms_body EXTRA key 是如何被人们发现的?

我唯一的答案是直接从应用程序本身收集解决方案(我认为反编译别人的工作已经不应该是正确的方向,但它是我唯一的方向)。所以我(这是通过支持短信的新环聊应用完成的):

  1. Download the app from my rooted device using adb in /data/app/
  2. Decompile using apktool and get the manifest file. From this I can see what IntentFilters are defined. I cannot see anything to do with EXTRAs because they are not declarable in an IntentFilter
  3. I try and get the source code by obtaining the classes.dex and decompiling using dex2jar and then view with JD-GUI and attempt to interpret barely readable 'half-decompressed' code to find use of the EXTRAS that are passed in with the Intent.

那是我尝试这样做的尝试,似乎即使在第一步(反编译其他应用程序)这也不是您应该前往的方向找出与明确需要的其他应用程序通信的语言与之交谈(应用声明一个IntentFilter 以声明它想要接收通过该过滤器的任何数据)。

唯一明显的答案是,可以通过 Android SDK 中的类访问某些内容,应用声明和定义它们希望接收的信息。我在这方面找到的最接近的是 PackageManager.GET_INTENT_FILTERS 标志,has not even been implmented.

  • 我该如何弄清楚如何正确生成 Intent 以传递给需要此数据的应用?
  • 最重要的是,我应该如何找到正确的 EXTRA 以通过 Intent 传递?除了 apk 的源代码之外,它们是否在其他任何地方定义?

我一定遗漏了什么,因为在严重依赖应用程序间通信的手机操作系统中,为什么获取基本通信协议(protocol)会如此困难。

最佳答案

为什么你这么确定你错过了什么?

我认为这类似于找出 API 公开的某些命令。如果您运气好(java 类、带 wsdl 的 SOAP API),它实际上会告诉您可以做什么。但如果不是(REST API),你就会“卡住”阅读文档。这是一种实际的可能性,因此“我该怎么做”不必有答案。

在这种情况下,正如您发现的那样,没有一些类似 java 的“契约(Contract)”来阅读和弄清楚您可以做什么。也没有像 wsdl 这样的可访问文件,您可以使用它来查看您可以做什么

因此,您将不得不阅读您要使用的应用程序的文档。如果没有,您可能只能得出这样的结论。

除了技术限制外,您通过反编译找到的解决方案还有问题:因为它可能会发生变化。如果仅记录了某些额外功能,则说明您依赖于“隐藏”功能。第二条路,但有相同的问题,然后是一些,试图找到使用 Intent 的其他代码(如 stackoverflow 问题)。

关于java - 如何找到什么 'extras' 添加到与应用程序一起使用的 Intent ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20635133/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com