I have a public transport app for one country and I want to create a separate app for another country. Most of the code will be shared, but I need some classes to have different implementations for example TransitProvider.
Is it possible to share code using Android Library Project? Can I do the following?
putExtra("KEy",value) and then start that app. On the other hand, if you want to read some data from an app, it's possible if and only if that app allows you to do so. Data generated by the app is private by default. if that app doesn't design a mechanism for some third apps to pass data, it's impossible to do so.
Android uses the action ACTION_SEND to send data from one activity to another, even across process boundaries. You need to specify the data and its type. The system automatically identifies the compatible activities that can receive the data and displays them to the user.
Android inter-process communication At the simplest level, there are two different ways for apps to interact on Android: via intents, passing data from one application to another; and through services, where one application provides functionality for others to use.
You can easily share data between Android apps using the "Share" Intent. Intents allow you to utilize components inside and outside of your app with very little extra code, and a nice clean decoupling of components.
Is it possible to share code using Android Library Project?
Yes. That is the primary purpose of a library project. If you do not need Android resources, you can also use an ordinary JAR, created in a separate project.
Can I do the following?
You cannot have the same class (in the same package) defined in two places, if I understand your proposed steps properly.
You should:
AbstractTransitProvider
in the library project or JARAbstractTransitProvider
, for straight-up reuse, in the library project or JARAbstractTransitProvider
, in their own Java packages, in addition to using any concrete implementations supplied by the library project or JARIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With