How to acces android.provider.Telephony class? - android

It seems that this class is not public, and I have to access TELEPHONY_STATUS variables in this class because I see in android source code that the values can change considering what api version you are using.

Read this post from the android-developer mailing list.
android.provider.Telephony is part of the Open Source releases, but never included as part of the Official SDK.
You can view it, to understand how the system works, but you can't actually use it in your apps.
As it says in the post,
No, it does not appear in the SDK, and this means
you should not try to use it from your applications.

Related

Cannot resolve android.net.SntpClient class

I am trying to use the class SntpClient that should be in the android.net package, but Android Studio is telling me it cannot find it. Indeed when I look through the source jars (of both API 19 and API 21), the class is not there. However according to grepcode it should be.
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4.4_r1/android/net/SntpClient.java
What am I doing wrong?
Google has chosen not to make all public classes available as part of the SDK. Visibility is controlled by the #hide comment tag as described here.
I'm not sure why they chose to hide SntpClient particularly, but provided you respect the terms of the Apache license you can copy the source into your application without much modification.

General: Howto change Android core API classes?

This is just a general question for my information. I know how to create standard Android apps, but I was wondering: How is it possible/how do people enhance Android core functions and dig deeper into the system?
For example:
Let's assume I want to adapt the DownloadManager class, which is used by many apps. So, for example, one can adapt the class so that the download-text, which is displayed in the Notification bar under the download progress, is somehow changed.
Excuse me the following stupid questions, but I have no idea of these advanced topics, that's why I'm asking here ;-)
It is possible to change (for example) the DownloadManager class, so that it has extended functionality which will then be used by 3rd party apps, right?
Can the patched class then be put in the Play Store for other people to download/extend their DownloadManager functionality?
Will people need Root to be able to install such a change?
At most important: How can someone alter an Android API class? I'm really a noob here: I don't know where to get the source-code from, how to replace the standard with the enhanced class, what's needed for that, etc. Is there even a tutorial on advanced topics like this?
Please enlighten me a little bit :-)
is possible to change (for example) the DownloadManager class, so that
it has extended functionality which will then be used by 3rd party
apps.
Yes, of course, Android source code is opened under Apache license, you can modify this source code, and public into the world. For some detail about DownloadManager class and many other class, in Android OS Structure, those class is programmed on upper layer, often totally in Java.
Can the patched class then be put in the Play Store for other people
to download/extend their DownloadManager functionality?
I don't understand your question so much. In Play Store (and another android app store), people upload their application (in funny sentence, upload the source code has been compiled), so how can you upload a source code for user extends their apps ?
You can public your source code to github, or another place that programmers often meet, so they can view your source code, and often give you valuable ideas and comments :)
Will people need Root to be able to install such a change?
if advanced user, they can install new Android OS for their device. But I think, this answer is further than you really need.
Where to get the source-code from, how to replace the standard with the
enhanced class, what's needed for that, etc. Is there even a tutorial
on advanced topics like this?
In Android SDK folder, there is a folder named "Source", you can go there and see many Android source code. You can take that, read, and modify what you want. some part of Android is not here, you should google for this, it easy to find on internet.
But you should remember, when you modified this class or that class, it not belong to Android OS again, you must import this class file to your project as normal class.
So, if you want to modify base Android APIs : those APIs often write all in Java, and you read them and understand carefully, modified some part if you want, and import this class into your project.
And last word, why you should do that :) Because you can extends the class you want, and put some additional features for this class. It's easier and nicer.
Hope this help :)

Create Android app using API that reference JAXBContext

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!

API missing from PackageManager

It's weird I found PackageManager has public APIs like installPackage(...)/deletePackage(...) although in the comment it's marked as Hide, here http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.2_r1.1/android/content/pm/PackageManager.java#PackageManager.deletePackage%28java.lang.String%2Candroid.content.pm.IPackageDeleteObserver%2Cint%29, but the reference page google provides hide this API.
So my question is how can I access such APIs?
Thank you all very much for help.
Kindest regards,
Nessus.
It was declared as public just to simplify the SDK developers life. But it never was expected to be called by outside developers. See also this post.
But if you really need to call this method, you can use reflection. Thought I suggest to look around for an alternative solution using official API.
In general you should not use "hidden" APIs in your applications. These methods are for internal usage and can be changed or even removed without notice. They are often not available for non-system applications due to permission restriction. If you want to use these APIs in your application then you may build your app within the platform build.
There is also a workaround to build application that uses hidden API in Eclipse: you can collect compiled framework libraries from the platform build and add them to build path as "User library", framework_intermediates/classes-full-debug.jar should be enough for the package manager.

What is recommended way to include android source code in addition to android SDK?

I am a new developer for android programming. I understand android SDK does not contain all classes from android source code. For example, AtCommandResult.class is missing (hiding) from android.bluetooth package in the SDK.
Sometimes, however, I want to use the hidden code in my app and I wonder what would be the best way to do that. One approach I can think of would be to include its corresponding source code in my project with different package name to avoid conflict with existing core. But problem with this approach would be I have to maintain the code by myself from that point. One or two classes are OK but you know where I am going.
Is there any better way other than bothering google to include the code in the SDK? Thanks in advance.
You may want to use a .AIDL file:
http://developer.android.com/guide/developing/tools/aidl.html
Those can already be used to access for example in Telephony functions.
Code example here:
http://code.google.com/p/auto-answer/source/browse/trunk/src/com/android/internal/telephony/ITelephony.aidl?r=13

Categories

Resources