Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to do with multiple Android apps that share about 90% of source code?

Tags:

android

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?

  1. Have TransitProvider (that extends AbstractTransitProvider) in the library project. The class has methods left unimplemented.
  2. In application project > AndroidManifest.xml I have different package name than in library's manifest. I have also TransitProvider in this project, that is in the same package as the library's TransitProvider.
  3. When I use TP in library project code, the implementation from app. project should be used (ie application project's TP overrides library's TP).
like image 735
fhucho Avatar asked Oct 21 '10 13:10

fhucho


People also ask

Can an app read data from another app?

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.

How do I transfer data from one app to another Android?

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.

How can two different Android applications interact explain in detail?

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.

How a service can share the data with other components in Android?

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.


1 Answers

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:

  1. Define AbstractTransitProvider in the library project or JAR
  2. Optionally have one or more concrete implementations of AbstractTransitProvider, for straight-up reuse, in the library project or JAR
  3. Apps using the library project or JAR can have their own concrete implementations of AbstractTransitProvider, in their own Java packages, in addition to using any concrete implementations supplied by the library project or JAR
like image 132
CommonsWare Avatar answered Sep 27 '22 17:09

CommonsWare