Implementing downloadable code and content plugins for Android - java

I'm kinda new to a plugin development in Java and Android, so I wanted to ask this basic question.
Consider that I have some framework which has some Factory which can produce certain classes - these classes perform some plugin-like functionality. I want to implement a plugin system that would be able to somehow download new plugins from some server and make them available for that Factory for creation.
And the basic requirements for plugin is:
it contains code by implementing some common interface
it contains resources (for example drawables)
For example this might be a "shapes" drawing app. each plugin has code to draw() a shape, optionally by using bitmap for filling that shape - in this case bitmap is supplied with a plugin as a resource.
How should I go about this? Any pointers to google search terms and hints are appreciated, thanks :)

I don't think you can do this on Android, because of security restrictions. It is very likely that your only option is to distribute plugins as separate application in the Market (like Doplhin browser does).
However, the problem to be solved is: how are you going to discover those plugins? To answer this we would need to know how do you intend to use those plugins. If should be easy if your plugins are plain old activities.
I found this post for you: http://mylifewithandroid.blogspot.com/2010/06/plugins.html

Related

Using android palette class in desktop java application

Android developers have created a great class to isolate colors from an image
https://android.googlesource.com/platform/frameworks/support/+/refs/heads/master/v7/palette/src/android/support/v7/graphics/Palette.java
However I could really use this in a desktop application. I tried ripping the class from the library (as recommended to me , during a Devox java conference by one of the android devs) but he probably didn't realize I would have to drag half of the android library with me then eg: Bitmap, Color
Does anyone know of a tool that might be able to strip the classes I need retroactivly from the library, or give me a better way to solve my original problem, a java class that will give me the dominant colors of an image together with their inverse and adjoining colors ? I can't write it from scratch cause we just don't have the budget/time to do that :(
I stumbled upon your question and I also found this lightweight library on github that is a port of one of the javascript libraries that Chris Banes references in the blog post mentioned above.
It's pretty good at extracting the primary color for images quickly. I would still love it if someone had a way to extract something like what android calls the "vibrant" color. Ideally I would love a way to mimic exactly what happens in the android library so i could have a seamless experience between my android, desktop, and ios experiences. I still haven't found that one yet.
Another Java port - https://github.com/trickl/palette. I wrote this one myself (I was unaware of the existence of other ports at the time). It's a pretty direct port and includes a bunch of the original tests.
There is this Palette ported library. You can use it in your Gradle based java project by adding jcenter() to your repositories and the next dependency into your build.gradle file.
dependencies {
...
compile "com.loyalsound:iris:1.1"
}

Java Android Manually Project Creation

I have few questions:
Is it possible to create an Android App with Java and setup all
myself?
If yes, what are the important things, that must a App have?
Is there a tutorial?
If someone want know why:
I want to understand all exactly and want to have the full control.
The Android SDK with eclipse have so many features(For the first small projects too many).
In the best case I want only link the Android library jar, but I think its not so easy and there are a few Mord things Like the App manifest ...
I hope someone understand me and can help me.
I want to understand all exactly
I doubt that there is anyone on the planet that understands it all exactly.
Is it possible to create an Android App with Java and setup all myself?
I do not know what "with Java" means here. Based on the rest of your question, I am interpreting this as:
Is it possible to create an Android application project without an IDE?
In that case, you are welcome to:
Create a project using android create project, designed to be built with Apache Ant, or
Create a project by copying an existing project or downloading a bootstrap project, then use android update project to create the Ant build files
If yes, what are the important things, that must a App have?
The android create project command will create a complete "Hello, world" application, ready to be run.
Is there a tutorial?
I will settle for pointing you to the documentation for creating and building projects on the command line, in hopes that perhaps that is what you are referring to.

Build Android native library with Adobe Air

I'm currently working on an Android application built with Adobe Air sdk, in AS3. I was wondering if it's possible to compile a kind of UI library that I can import in a Android native application (Java). Basically, I would like to build my UI with Adobe Air, but the main part of my application with Java, the native way.
What I have in mind is to convert the adobe air-generated APK into a Jar file I would import in the native application project, and call some functions that display something on the Screen.
Is it possible? I think it may be possible, because when I don't import Adobe Air SDK in the application, I must install Adobe Air application with the Play Store to make my application working. I don't find lot of things on Google about that :s.
Thank you for your help.
Yes it can be done (in theory), but hold on to your hat, it's a bumpy ride!
I see it is a very old question, with a new bounty (the questioner has not logged on for 3 years!), but here we go...
This method goes to the heart of how android java apps are constructed and run (i.e. DEX, so it will work with adobe-air or ANYTHING, it is fundamental [general method]). (by the way you use the word native in a confusing way, native is commonly understood to mean the JNI (c++) library element of an app).
You say:
"What I have in mind is to convert the adobe air-generated APK into a
Jar file I would import in the native application project, and call
some functions that display something on the Screen."
Android programs are compiled into .dex (Dalvik Executable)[now called ART but binary compatible] files,
which are in turn zipped into a single .apk file on the device (with other things like the manifest and resources). (unzip a .apk and look inside).
A .jar file contains DEX files (zipped). (unzip a compiled .jar and look inside).
I have done some work like this before, here's a link to a tutorial and coding examples [tested by me] (in android studio + gradle) [custom build elements are usually needed (I also give an ant example)].
See my stack-overflow answer Dynamic loading of DEX files
This in theory answers your question, but it's fundamental stuff, complex and has limitations that make it hard to code and maintain (resources are a real pain in the a**e).
Question: This all seems very complicated and hard !
Yes it is ! It is an increadably silly an difficult thing to do! That is why we invented cross platform frameworks, (and for web based code javascript/css/html5...). Failing that PORT the code.
I'm more of a Flash/AS3 coder than Java so can't give you a full answer but...
A better approach might be to just render your SWF-based User Interface itself via Java code (as opposed to compiling SWF into APK format then trying to embed Flash APK inside Android APK).
This way your SWF can also communicate with Java functions (via AS3's external Interface class). Making it easier to trigger Java functions when a button on the SWF U.I is pressed etc..
You just have to find an SWF render library for Java.
Maybe check out SWFTools. Particularly the SWF Class looks promising. I have not tested this library but it might help you.
I am not a Adobe AIR developer at all, however, I have developed a few Android App with both native environment and with some kind of framework (specifically PhoneGap). So, may this can help you.
I don't think that there would be any tool which could directly convert mobile apps build using frameworks like Adobe AIR, PhoneGap or any other HTML5 based framework to a native Android app because technically it is very difficult and unfeasible to do a proper mapping between each and every element of HTML5 (or Flex element in your case) to a corresponding native control or logic. The best you can do is use plugin mechanism provided by your framework to interact with Java and vice-versa and basically that is why the framework is there. For most of HTML5 based frameworks there is a plugin mechanism which allows developer to interact with native functionality (like Background Services, Activity or any other native resource). Even these frameworks are build using the same modular or plugin based approach and there major functionality (accessing Camera, Audio, SD Card etc native resources) works like this. We have to enable that feature before using that in our app.
So, look for plugin type of mechanism in Adobe AIR.
Hope this helps.
Maybe this is a dirty way to help you, but you can :
Install the adobe air program in one computer
Copy the files of the install folder of the adobe air program
Embed all this files in the java application
Install the java application
Save the adobe air files in one folder
Start the adobe air with java (like you will do it with the console, a simple call to YourAirApp.exe)

How to take a picture of in panaroma mode?

I want to make an application that allow the user to take a picture of text either from android device Gallery or from android Camera application in a Panorama mode .But i can not find any source or tutorial to do this.How can i do this in my application? how to make an application that take picture from android camera application in a panaroma mode?
Thanks in advance.
I don't know if it's still actual for you, but hope it will be helpful for someone.
Panorama feature is already implemented in standard android camera at least since Android 4.0 (perhaps it was available in even earlier versions but I'm not sure, you can check it), so since source code is open for everyone, it might be the easiest way just to copy required functionality.
Although you can download source of apps from https://android.googlesource.com/ (you want LegacyCamera or Camera), you can't just open project of any standard app in Eclipse or other IDE. For example, LegacyCamera depends on Gallery2 and other dependences that might be hard to be resolved.
I spent several days trying to move panorama feature to separate project. You can download it from here: https://github.com/yankeppey/PanoramaSample . Several remarks:
Functional core (creating one panorama image from several ones, progress notices, etc) is on native part.
I used java code from from LegacyCamera which was used in Android 4.0-4.1, not 4.2, because it was significantly easier for me. Native part is taken from 4.2, it has only minor changes inside and almost the same JNI interfaces.
This project is just to help you move panorama feature to your own app, it's not like kind of library, don't expect clean code without bugs, it's just pretty dirty and buggy project. If I have time I'll try to make it cleaner, but there is no warranty :)

Making a pluggable Android messaging app

I'm making a messaging app and I want to be able to extend it by using plugins.
The plugin might, for example, replace :) with a smiley image.
I've written some test code which uses intent filters to find the plugins, but I can't find a way to create an instance of the that plugin class.
Is it possible to do this, and if not, what would be the best approach/best alternative to this?
Thanks.
Because applications in android each run in their own VM, I don't think the classloader of your application will have access to the classes defined in the plugin. What you can do, however, is to pass the data between your main application and the plugin via Intents. If the plugin needs data from the main application, create a ContentProvider to make the data available.

Categories

Resources