Managing the project structure of larger and more complex apps - java

This is a bit of a basic question/s and pertains to project structure. It's just a basic concept I have missed in android. (as a result of being self taught).
With an app that has many classes, activities and fragments, it's becoming busy in both the java and res folders.
I am unsure what is the best way to proceed with managing larger projects.
For instance, if I have a various sections, bluetooth, wifi, gps, etc. And for many of these they are reusable code "packages" or "modules" (I am not sure of the correct word).
How should I go about formatting my project?
Using packages?
Is there a dll concept equivalent?
There is this question here:
Is there any DLL or DLL like concept in Android?, but it doesn't really help clarify this issue for me.
Any feedback is appreciated.

How should I go about formatting my project?
It depends on your needs. If you want to move some part of logic to a library, you can do that by creating an android library project. See Library Module section: https://developer.android.com/tools/projects/index.html
Is there a dll concept equivalent?
If you want to have a compiled version of that library project (like DLL) you can generate a .jar file. Refer this link: How to create jar for Android Library Project
So, you can link android library project directly, or, compile it first, and then include as a .jar file.

Related

Is there any way to make VS Code correctly handle Android packages?

I am using VS Code to study and develop android projects. I am using the Code Runner extension that handles C/C++/Java and many more file management and allows me to jump between files and find source of objects/classes etc.
But it also gives a lot of errors because it cannot resolve the android packages. The error is:
<PackageName> cannot be resolved to a typeJava(16777218)
Is there any way (extensions, options, etc.) to make it handle packages from android or make these packages behave like Java packages?
yaa there is called "Android" which is under the name of "adelphes"

Plugins to add features to java

I'm working on a project that requires to add some features to an existing java application using Netbeans. After searching the net, i founded that I should use "plugins". I didn't hear of plugins before.
I have a java application that I should download it from the net, then lets say I have to add a button, when clicked, calls a function that is written in some class in the application. In other words I want to make a new class that is able to access the classes and functions that are written in this application.
What I understood from searching the net is that:
-In the downloaded project's folder there is a folder named plugins.
-This folder contains zip files that contains classes and other stuff.
-I should make a plugin and add it to this folder in order to add a specific feature to the application.
That's what I know, if there is something wrong in what I said, I'll be thankful to correct to me.
Now, my question is that I want a link or website that can teach me how to create and add a plugin to an existing java application. Thank you :)
That entirely depends on the java application you're talking about. Not every application has a Plugins functionality. And not every Java Application uses the same Plugin API. The best bet is to go to the site of the App you're talking about and see if they offer a documentation about their Plugin API.

Where to place META-INF in Android project

I'm writing an app that needs to load dinamically plugins from external libraries.
My first idea was -with very little immagination- to use Java's ServiceLoader and googling a little bit I found documentation that states that this kind of action is supported by Android: http://developer.android.com/reference/java/util/ServiceLoader.html
However I really don't understand where to place my META-INF folder (I'm used to Maven, but I can't use it in this occasion).
Could someone tell me where to place the META-INF folder and what to do to have it working in the usual way?
Stefano

Control NetBeans Programmatically using a NetBeans Module

I know I should probably be using Eclipse but whatever...
Usualy at computer science contests I go to, we are given some sample data sets for the problems, such as "prob01.in, PizzaProblem.text, ect.". I am writing a NetBeans Module to make a project and then fill the project with java files of the input files, in the specified location.
So, on to my question. Is there any way to "control" NetBeans, and use it to make and open projects and files?
I did a breif google search and did not find anything useful.
Thanks,
-EpicDavi
http://wiki.netbeans.org/OpenProjectsProgramaticallyInNetBeansIDE#Tutorial_.7C_Open_Projects_Programatically_in_NetBeans
This page only tells you how to open a project programmatically in a Netbeans module, but it should set you on the right path. Unfortunately, I'm not well versed in NetBeans so I don't have much other insight to offer.

Making a redistributable component or library for Android

I'm just starting out on Android and Java programming, coming in from a C++ background. I was wondering - whats the best way to go about making a library/UI widget/component that I can license to third-party developers?
In C++ I'd ship the customers my headers and *.a files, but I don't know the equivalent in Java.
Are there any good resources or links about this, maybe even from general Java development standpoint.
you can define activities/services that are available for any other application running on android:
"A central feature of Android is that one application can make use of elements of other applications (provided those applications permit it). For example, if your application needs to display a scrolling list of images and another application has developed a suitable scroller and made it available to others, you can call upon that scroller to do the work, rather than develop your own. "
http://developer.android.com/guide/topics/fundamentals.html
Activities and services have some use but there is a whole class of functionality (fancy table viewer for sql) that isn't covered. You can do jars but I don't think you can have android resources in that file. The work around would be to have a Jar and require the user to copy and paste some text into the apps resource directory. You can look at the admob.com android SDK for an example of this.
Not sure about how Android handles this, but the typical distribution of Java code is a .jar file. A .jar is basically a zip file containing all of the compiled .class files in a Java project. There might also be resource/text/etc. files within the .jar. There is no concept of a header file in Java, so all you need are the .class files, and possibly a manifest file to provide some additional meta info about the .jar.
http://java.sun.com/docs/books/tutorial/deployment/jar/
(This is just a general Java answer, it may or may not apply to Android)

Categories

Resources