无法使用SAF检索自定义附加信息

huangapple go评论79阅读模式
英文:

Can't retrieve a custom extra with the SAF

问题

在用于触发android.intent.action.CREATE_DOCUMENT操作的Intent中,我使用myIntent.putExtra("myPackage.MY_EXTRA","toto")添加了自定义额外数据。

onActivityResult函数中,当我尝试使用intent.getStringExtra("myPackage.MY_EXTRA")检索此额外数据时,我得到一个空的Stringintent是在onActivityResult函数中作为参数接收的Intent)。

您有关于如何解决我的问题的任何想法吗?

英文:

In the Intent used to trigger an android.intent.action.CREATE_DOCUMENT action, I add a custom extra with myIntent.putExtra("myPackage.MY_EXTRA","toto").

In the onActivityResult function, when I try to retrieve this extra with intent.getStringExtra("myPackage.MY_EXTRA"), I get a null String (intent is the Intent received as a parameter in the onActivityResult function).

Any idea on how I could solve my problem?

答案1

得分: 0

你想要的可能不太可能适用于任何startActivityForResult()调用。在Intent上放置一个额外的内容会将该额外内容发送到另一个活动。没有要求将该额外内容返回给您,很少有(如果有的话)活动会这样做。

因此,将数据自己保存在您的活动字段中。

英文:

What you want is not likely to be available for any startActivityForResult() call. Putting an extra on an Intent sends that extra to the other activity. There is no requirement for that extra to be returned to you, and few (if any) activities will do that.

So, hold onto the data yourself, such as in a field of your activity.

huangapple
  • 本文由 发表于 2020年4月4日 21:48:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/61029073.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定