I am developing an app which by design should accept request from other apps(with some authentication token) and should be able to send requested data(media file or address of media file in local storage). I am not able to do it without switching between apps. Is there a way to do so that i don't know? Thanks in advance.
2 Answers
https://developer.android.com/guide/topics/providers/content-providers
Content providers can help an application manage access to data stored by itself, stored by other apps, and provide a way to share data with other apps. They encapsulate the data, and provide mechanisms for defining data security. Content providers are the standard interface that connects data in one process with code running in another process.
Without further context on exactly what it is that you are building, this is the general approach you can use to share data between applications.

- 371
- 2
- 9
-
1Thanks Paul, I want to create an app that can ideall be running in background and other apps when running can make a request to my app to retrieve some information or media file(without leaving the app user is already using) and after that data is retrieved and processed, a message is again sent to the background app(my app) which it stores and processes in background. I hope you can help with this information. – Lokendra Choudhary Apr 28 '20 at 22:05
-
Sounds like you are building an API? Can you just build your library and expose an API for other apps to consume? Or is there some use case you are trying to solve? – paul_hundal Apr 28 '20 at 22:15
-
1I may use API way. Just that the data that needs to be sent by my app(hidden in background) to running app keeps on changing. And only trannsaction happens between apps and not any server. How can i build API for such use case. And in case of API, will my app(hidden) open up everytime api is called or can it be done while running in background silently? – Lokendra Choudhary Apr 28 '20 at 22:19
-
1You can create an API like ```MyApi { fun exposeSomeData(): LiveData
} ``` MyApiImpl { .... whatever data you want to expose can be here, just return a live data } ``` Application X consumes Api (gradle -> api your.published.api) Whatever changes you are making can be observed in Activity/fragment of the users app. Not sure if this is what you mean, but since you are the library owner you can provide the data however you want, only the API is consumed by the client. – paul_hundal Apr 29 '20 at 00:22 -
1Thanks Paul... I will try this and will let you know. – Lokendra Choudhary Apr 29 '20 at 05:02
Sounds like you want to run some task in the background which other apps can invoke. See the documentation on background work to get started. If this does not help you solve the problem, please review the How to Ask Questions page and update your question to clarify specifically what you need help with.
Hope that helps!

- 9,338
- 1
- 26
- 32