Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio "mobile" and "wear" project modules, shared components location

In my Android Studio project there are two android modules "mobile" and "wear", these seem to be the views and controllers for the types of android devices that will be able to run this application

I expect them to share some logic, such as the model files and POJOs so where should that be stored? I expect the "mobile" module to do a lot more heavy lifting than the "wear" module, but should I put the model objects in that module, or should I make a new third module that they can both use? (or some other design paradigm)

like image 210
CQM Avatar asked Aug 26 '14 12:08

CQM


People also ask

What is Android multi module?

A project with multiple Gradle modules is known as a multi-module project. In a multi-module project that ships as a single APK with no feature modules, it's common to have an app module that can depend on most modules of your project and a base or core module that the rest of the modules usually depend on.

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

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.

What are modules in Android project?

Modules provide a container for your app's source code, resource files, and app level settings, such as the module-level build file and Android manifest file. Each module can be independently built, tested, and debugged. Android Studio uses modules to make it easy to add new devices to your project.


1 Answers

Take a look there: https://github.com/tajchert/SWear_Weather

I created common module that (in my case) have constant variables, and is shared between phone and Wear module.

About where to put your objects... if you expect to use same objects on Wear an mobile, put them in common project so they are automatically shared between those two (no code duplication), but if particular object is used only on mobile and there is no need in future to add him on Wear, just put him in mobile project.

Also common project can allow you to share stuff like assets (icons etc.) between mobile and Wear device.

like image 131
Michał Tajchert Avatar answered Nov 09 '22 05:11

Michał Tajchert