1

Problem

I have multiple apps that have the same exact layout and functionality. Think of it as: creating same app for multiple pizza restaurants.

Now I need to make an android module that will just extract everything(activities, layout, code, etc..) to these apps without the need to manually create activities and then call the xml that is in my module.


Steps I've done

I followed the module tutorial on Google's Android site here. Specifically,

  1. Convert an app module to a library module
  2. Generated the AAR file
  3. Add the library as a dependency

Details

The previous steps work, however, I will have to create all activity in each single project, then modify the setContent() to call my library xml setContent(R.layout.**myModule)

  • How would I go about if I want to make the module copies activities and layout xml to another project without the need to manually creating them ?
  • Is there a better approach than using a module ?
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Suhaib
  • 2,031
  • 3
  • 24
  • 36
  • You need to make a template for that and add it in android studio's template folder – Akash Dubey Jul 26 '17 at 14:21
  • What you are describing should work without any issues. Why cant you just use startActivity to start activity from your library? – Okas Jul 26 '17 at 14:34
  • @Okas, damn, thank you for this. I searched a lot and all the topics/questions never went beyond the import module step. So basically, create an intent inside my mainActivity that calls the mainActivity of my module ? Can you make this an answer so I can mark it ? off-topic: it seems the app is crashing because of twitter sdk in my module, `Didn't find class "com.twitter.sdk.android.core.TwitterConfig$Builder"` would you know if this is because I added the sdk in my module's gradle instead of my current app ? – Suhaib Jul 26 '17 at 14:52
  • It is probably better to ask a new question about your TwitterConfig issue. – Okas Jul 27 '17 at 13:00

1 Answers1

0

Just start your library activity with startActivity, no copies needed.

Okas
  • 2,664
  • 1
  • 19
  • 26
  • I created a new question related to your answer here https://stackoverflow.com/questions/45353701/launching-mainactivity-found-inside-my-module-library-works-but-doesnt-load-lay – Suhaib Jul 27 '17 at 14:32