Can anyone tell me, how to import Android hidden/internal API's into my application?
For example, com.android.internal.telephony. How to import this APi into application?
Thanks in advance.
If the classes are available at runtime, but not compile time, yes you can't compile against them directly in your code but you can still try to load them via reflection. We used this in Android 1.x to load a hidden internal class that controlled the LED light on some devices. It is difficult since every method call turns into several lines of calls to java.lang.reflect classes. See here:
http://www.google.com/codesearch#k59QJW14udA/android/src/com/google/zxing/client/android/camera/FlashlightManager.java
Of course, these APIs or classes would not at all be guaranteed to be present on all devices, and could change or disappear, so this is brittle. And it may be that there's a SecurityManager protecting access to certain internals too, I don't know.
Related
I am a new android developer. I want to develop an app which can access SIM Tool Kit in android mobile. But I haven't found the exact solution online. I found 2 examples:
https://github.com/android/platform_packages_apps_stk
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.4.2_r1/com/android/stk/StkLauncherActivity.java?av=f
when I import com.android.internal.telephony.cat.Duration class in ADT, it does not find it.
I also found this class here:
https://android.googlesource.com/platform/frameworks/opt/telephony/+/e005c3c44109c9b4a8d25f05e8b7133d5ef55ead/src/java/com/android/internal/telephony/cat/
But I am not able use it.
If you were to google a little bit, you'd find out that this is impossible.
com.android.internal.telephony.cat.Duration has an #hide annotation that means it's not accesible through the SDK
The whole internal package is meant to be internal, i.e. used by android not by developers.
STK itself is not accessible to external apps
However there's also reflection which may be used to access hidden methods. Though I didn't bother to try, this might help.
I realized that Gallery class in Android is deprecated, but I can still build my application and it runs correctly.
I don't care much about performance, since it will contain 2-3 pictures at most.
What I'm wondering is, is it safe to use Gallery ?
Will it work in all devices (including API > 16)?
And I hope that Android Dev Team replaces Gallery with another widget, instead of making us write our own galleries using HorizontalScrollView etc.
There are certain functionality deprecated by the Android Engineers just to make the developers use a newer implementation of the same. For example the Dialog Fragment requires a lot of coding to do the same task a showDialog() can possibly do. You are completely safe on this one as far as I know. At the same time, there are some other deprecation made due to security issues as well. In the case of Gallery, I understand that there is nothing wrong with using the deprecated class, except that it is deprecated. You are safe.
I am creating an app showing local events for android. I was hoping to use the Eventful API, since that came with its own java-based client library. However, I'm not sure if it's fit for Android, since I know a lot of these java based client libraries use stuff Android doesn't support.
So, does anybody know if it works?
My entire project is available # github if you want to check it out for yourself.
The API is found here.
Android does not have have issues with Java client libraries. It is build on top of standard Java, and can use all of the framework features.
Furthermore, it looks like this API offers a RESTful interface, which is for sure supported by Android.
Bottom line, I do think you can use this API in Android without issue.
I'd say the easiest way is to compile and run an application that embeds the library and tests a few methods.
Typically, you may have issues with the way the networking is handled. There are 2 main ways in android to do HTTP, the Java and the Apache way, I think the Java URL API is fully supported and very close to the actual Java version, but the Apache has some hidden differences.
The main risks you'll have are A/ that it uses classes or packages that are not present on Android. B/ that a class does not behave as expected, which does happen from time to time, as the Android implementation is entirely specific.
Apparently you have already tried to run an android app with the library included? Did you encounter a specific error? If you, can you post the stacktrace?
I am a Computer Science undergraduate student and I am creating an Android app that using an API to interact with an execution server.
The server takes a xml file and do various stuff with it(get data, process data etc.)and then gives back data as output. Both input and output are exchanged via this API.
The problem is that the API references code from javax.xml.bind, for example, JAXBContext while android doesn't have javax.xml.bind package in its core. (a well known issue)
Feasible solutions on the internet seems to be repackaging the code I need, but I don't know exactly what suppose to be.
Since the API reference classes in javax.xml.bind and javax.net, I guess I have to extract code from these 2 packages and make them part of the API (I have access to API source) and then repackage the API. However, I guess classes inside javax.xml.bind might have dependencies on other classes that not supported by Android, so does javax.net. (Please forgive me if this is stupid thought...)
So anyone know : whether there are classes, which codes in javax.xml.bind and javax.net depends on, not supported by android ?
Bit of tricky question really..
I will be really appreciated if you can provide a work around that enable a Android app to call an API that reference codes inside javax.xml.bind.
Try JiBX (http://jibx.sourceforge.net/), it's a small and fast footprint, Android compatible, XML binding framework.
I ended up with repacking those package which exists in standard Java library but not in Android. Basically, just get source code of all those missing packages and then put them into the API source and rename them into a name that is different from the original one and then change corresponding code in API that reference these methods as well (you have to use a different name, otherwise code reference methods in these package will still looking for methods in the core Library (i.e Android API)
Anyway, hope it helps. If you have the same problem.
If you have any better suggestion. Please share it!
I would like to know if SNMP is supported in Android(2.1)?
If it is not available, is it possible to port the snmp source for Android?(some pointers plz..)
If it is available, how can I test the presence of it in my device.
All pointers are welcomed.
Thanks,
Sen
SNMP4J 2.x can be directly used on Android without changing its sources. The logging can be set to a simple console logger by calling
static {
LogFactory.setLogFactory(new ConsoleLogFactory());
ConsoleLogAdapter.setDebugEnabled(true);
}
in your root activity. Of course, you can implement a Android Logging Adapter too and register it as shown above.
I know this is a really old question, but I was doing exactly what you're asking. The short answer is no, by default, SNMP is not supported on android 2.1. Because it isn't available, what I wound up doing was grabbing snmp4j's source code, and sticking it in android and making my own library. There are libraries (snmp4android comes to mind) but I found that it lacked certain classes I needed and did not have the whole snmp4j.agent branch.
There are a few dependencies and a few libraries that android is missing but most of them pertain to the log4j class.
To remedy that, just convert/make the switch to something like slf4j, which is a small logging library that you can include with your application.
I hope that answers some of your initial questions, and I hope this is still relevant even if it is an old question.