Android应用程序之间传递字符串数据 [英] Passing String data between Android applications

查看:101
本文介绍了Android应用程序之间传递字符串数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是通过简单的数据,如应用程序之间的字符串的最佳方式?字符串是一些字段是在发送者应用程序已知的,并且由接收器应用所需的

What is the best way to pass simple data such as a String between applications? The String is some field that is known in the sender app and is needed by the receiver app.

我看着将其存储在共享MODE_WORLD_READABLE preferences,但我不一定知道包名(这将存在于一个库),该值可以通过各种应用程序进行设置,所以它会是难以查找。

I looked into storing it in a MODE_WORLD_READABLE SharedPreferences, but I won't necessarily know the package name (this would exist in a library), the value can be set by various apps, so it'd be difficult to look up.

我想有两个应用程序包含BroadcastReceivers。当接收器应用程序打开时,它发出了一个自定义的意图发件人应用接收告诉它,它已经准备好接收。见状即意向,发送应用程序,然后将另一意向与我的字符串值到接收器应用获取。

I was thinking have both apps contain BroadcastReceivers. When the receiver app is opened, it sends a custom Intent for the sender app to receive to tell it that it's ready to receive. Upon seeing that Intent, the sender app then sends another Intent with my string value to the receiver app to get.

推荐答案

@CommonsWare你说什么是不正确。可以共享数据,例如两个应用程序之间的字符串。请看看这里:数据两个应用程序也是之间共享:的 http://developer.android.com/training/sharing/send.html

@CommonsWare What you're saying is incorrect. You can share data, for example a string between two applications. Please take a look here: Data sharing between two applications and also: http://developer.android.com/training/sharing/send.html

我在想同时拥有应用程序包含BroadcastReceivers。这是没有必要的。谷歌提供了一个非常简单和容易的解决方案和示例。

"I was thinking have both apps contain BroadcastReceivers." This is not needed. Google provides a very simple and easy solution and example.

这篇关于Android应用程序之间传递字符串数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆