React Native - Share code for different applications - android

I have a react native application called A, now I want create another application very similar to A, I only need change some colours the rest of the code is exactly the same. One option could be create a new application B and copy all the code from A and change the hard coded colours, obviously it doesn't look very clever because now I have to maintain two different applications.
There are any way to load the colours information from a theme file and then when I start the application determinate what file the application should use?

You can do it using product flavors.
Take a look at the docs:
http://developer.android.com/tools/building/configuring-gradle.html

Related

Kotlin How to create a template application

I have to create 2 application with almost the same design. But the backend i mean the way i receive data and i make request to my api is not the same. And there are also minor design such as color or bouton placement...
So i wanted to know if it's possible to create and app template i was thinking of creating a library module such as aar that would hold all the design then i would import it in both my application ?
But if i do that, is there a way to to update the design of the library within the app for exemple i assume that i want to change some color i could do it programmatically, but what happen if i want to change some button position or add rounder corner ? Do i have to provide methodes in my library to handle all those cases ? or is there a way to handle those within the app, meaning that the app could change some design of the library it self ?
In the end would like to have the logic in my app then give all information to the template library to render the design. So i would like to know if there is a way to implement such thing and what are the best practices to do it.
I have in my projects two ways.
Library, as you mention. I use it when there are routines that are common to several projects. It is possible to change color patterns and some style details. But it is often plastered.
Flavors - Build Variants https://developer.android.com/studio/build/build-variants
With build variants you can create one project/app with two versions, chandind only wat you need. This option is very good when you want to change color, endpoint, style, show or hide some system functionality. I use it and it's very good.

Can I Include an application within another

I have the source code for two applications. One is a legacy official app with package name com.officialaz.app and one is the new application I have created with package name com.media.mediaplayer. The manager wants the two applications integrated so that the second app becomes part of the first one. Given the fact that both applications have manifests and activities of their own, is this possible to achieve? Or should I use intents to interact between the two applications (installed separately on the device)? One thing that I tried was importing the source code for the 2nd app as a module within the 1st app. Then near the hammer icon I see two apps I can select from the drop-down menu. Running the app does not work and it says that e.g. apk_6.apk is defined multiple times. What do you suggest?
The simplest way to implement this is to use "Implicit intent".
In your legacy app, in the manifest add some custom url:
In your new app, add a button click event handler, and link it to open the custom url: Custom Protocol Url
You can also pass some data to and from these two apps. A relevant, but not exactly the same tutorial can be found here.
Google also has a formal tutorial on this topic.

Android - App with layouts only - without controllers

I'm programming an app in Android.
My client needs a 'dummy' like application, I mean, an app with all layouts but just navigable, without the actual controllers or activities, just navigate through layouts. By clicking buttons, but just pass to the other layouts without executing java or whatever code.
My question is, is this possible in AndroidStudio?
Or should I generate another kind of graphical app in order to accomplish this?
Any ideas?
Thanks in advance!
The short answer to your question (as I understood it) is no. You have to have activities to have an android app that will function. You could create a very rudimentary set of activities to do what you want.
However, if you are simply trying to create a mockup of what the app will look like for your client, I suggest using a tool like FluidUI. This will allow you to layout the general look and feel of your app without any actual code required.
Let me know if this helps!

How can I get information from another app

I am new to Andorid development.
I am trying to write a small application for Android device.
One thing that I want is to get information from another installed application.
EDIT:
I want my application to do A and B, and I found a application that already does part A,so what I am trying to do is to extend the functionality of the existing application
is there a generic way to retrieve information from another app?
#dprogramz gave a really good answer but to build on it you may want to take a look at startActivityForResult if you're looking to get a photo or use input from some external activity.
Documentation is here
What information?
If it is shared information that lives in a shared directory then it shouldn't be any problem at all.
If it is protected information you will have to give your app access to these files.
If it is "real-time" information you will have to invoke an API. take a look at the application class
http://developer.android.com/reference/android/app/Application.html
yes, there is a possibility to extend a app X with a feature A. You can add a new feature B to the app and make it more scalable and realiable,
only if-
Project is Open-Source:
You can contribute to the app via github and push changes.
If the owner likes it, you can be hire.
OR
Download the existing the project, make changes and upload it.

Android application design

I am starting to develop an application for Android and was wondering what the common application design/structure looks like.
In iOS, I would generally start with a RootController which contains a UITabBarController and fill this with 4-5 UINavigationControllers. Each UINavigationController would contain its stack with UIViewControllers.
What would a similar application look like for Android?
Start reading here. The basic building block is an Activity, you setup your UI, display data and respond to events in your Activity classes. Screen navigation is handled by starting other activities using intents.
I lay out my activities and my activity xml files. Then I code in the components that are needed in the activity classes. Then I set up preferences and my submenu etc. From there I do my support classes and glue it all together.
Egil.. The Android way is significantly different from the iOS way in that it is more like a web interface.
First: "Activities" or UIs can be killed at any time. In fact, rotating the phone can kill an activity. So that each Activity needs to be able to save its state in onSaveInstanceState and restore state in onResume. Furthermore, "shared document like data" is written in onPause() and restored in onResume(). The closest analogy in iOS is saving state on low memory warning.
Second: Activities are relatively independent of each other so that state needs to be passed between Activities (UIs) using intents or saved globally using say Application state.
It is possible to quickly move an iOS TabBar to Android using Androids Options menu, but there is no built in hierarchy of views like UINavigationController.
I have a table comparing and contrasting iOS and Android here.
Take a look at Android Design in Action, they have great video lessons on how to design Android apps!

Categories

Resources