سؤال

I have a question, currently a group of friends are developing an Android App. When we reach to the data handling between apps we supposely choosed a ContentProvider. But a guy told us that is way too much better to use an Intent to open an Activity and then return the data on the Activity.setData(Bundle); method. I don't thing this is a good practice, but I would like to know what you people think?

Is it really better to use a startActivityForResult(Intent) instead of a ContentProvider?.

Thank you very much

EDIT

I'm going to add a little example on this:

We have a scenario in where a Main App must use data from other apps to do some processing and on the main app and then show the info in the Main App View

Instead of using the ContentProviders of each app, the Dev proposed to use the an startActivityForResult() to start the other apps to process data and then set the result on the setResult(Bundle) method of each Activity triggered.

هل كانت مفيدة؟

المحلول

Instead of using the ContentProviders of each app, the Dev proposed to use the an startActivityForResult() to start the other apps to process data and then set the result on the setResult(Bundle) method of each Activity triggered.

If by "to start the other apps to process data", you mean "to show an activity to the user, to allow the user to interact with data", then using an activity is perfectly reasonable. Having that activity return a result is also reasonable, if the point behind the activity is for the user to pick something.

If, however, by "to start the other apps to process data", you literally mean that the other app is not going to be displaying anything, but is just going to "process data" to return a result, then an activity is a ridiculous choice. Whether a ContentProvider is a better approach than is a Service would depend a bit upon what "process data" means and what sort of results are being returned, but either would be preferable to using an activity.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top