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.
Related
my question is: Is posible to run a native app using a web app developed on phonegap?, I need to make that, I was reading about is necessary create a plugin to connect with other native app, but I'm starting to programming over phonegap I still don't understand much, and need to create that. But I need some very explicit.
Thanks.
Yes, you can create a PhoneGap native plugin that will enable you to create custom functionality in native code, and expose that to your PhoneGap applications via PhoneGap's native-to-JavaScript bridge. For more information about plugins and example of how to implement them check this tutorial:
http://www.adobe.com/devnet/html5/articles/extending-phonegap-with-native-plugins-for-android.html
In my debug version of game, I want to take actual information about game progress from many users on my email. As you know, code in libGDX is writing on native Java without Android context. What suggestions do you know for my problem?
See this page on the libgdx wiki: Interfacing with platform specific code.
What you need to do is create an interface with the methods you need. Then create a class implementing that interface in your Android project. (And other projects if needed, if not needed, just create dummy-files that do nothing)
Then instantiate that proper class where you launch your game, and pass in the object to the game and use it there.
Just follow the guide, and then you can use Android stuff in your game (through an interface).
You can try to use ACRA (Application Crash Report for Android). It automaticly sends you crash reports about every error in your application, that is very usefull by itself. And as I see it has method to declare your own varibles which will be send. That may be what you want. Also it's recommended by libgdx.
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
is there anyway to load a class from differen application ?
for example, I have two application and one of them has SomeExample class file. and I want to load it and use from another application.
I try to use, Class.forName. but this function throws "ClassNotFoundExpetion".
Is there anyway to load a class from differen application ?
No, sorry.
You can use startActivity(), startService(), and so on to launch components of another application, but each application's code remains separate.
While in most cases unadvisable (Android has many APIs to solve the common problems of inter-app communication without sharing code), it's possible by using PathClassLoader.
See also Android- Using DexClassLoader to load apk file.
I have downloaded the Android source code and can see the java source files for the built-in applications (e.g. com.android.contacts.ContactsListActivity). I am trying to discover how these applications re-use one another via Intents etc. I would also like to see how the UI layouts are assembled for these applications as a design for my own apps.
About using Intents and Intent Filters, if you are less experienced, it will be best for you, if you start learning from a book, then try something in your own application, and only after that dive in the pre-installed apps, IMHO.
You can debug built-in applications, just like any other application, if you have the source. If you want to install other version of a built-in app, you must use the appropriate Intent Filters and change the package name, so that it's different than the original application's.
If you are using the source code, browsing through the internal classes should be helpful, so take a look here.
If you want to examine the UI layout of the built-in apps, the hierarchyviewer in your Android /tools/ folder is your best choice (my second favorite of the bunch, after traceview).
Write back, if something is unclear or doesn't work for you.
Good luck.