英文:
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")检索此额外数据时,我得到一个空的String(intent是在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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论