Change the Network Operator with an Android App - android

I'm trying to develop an Android App which shows the signal strength of various network operators on a map. The problem is that the only way to change the network operator is by doing it by hand.
Any ideas on how I can get this information without changing it manually? I think that there are internal/private Android classes to do this.

You will need to use one or more of Google's internal APIs to do this. They are not, by default, available to Android applications for various (usually good) reasons. The API for turning tethering on and off and configuring it, for example, is not a public API and cannot be invoked directly by third party applications.
You will need to do two things. First, download the Android source code and find the API(s) you need to list and switch carrier. You can find the Android source code, and download instructions, here.
Second, you will need to use reflection to invoke the methods on those APIs. The best approach to this, and one I used myself to play with the tethering API, is to write a proxy class. Give it all the same methods as the API you want to use, and inside each method use reflection to invoke the API method. Any other technique will either (a) not compile without adding portions of the Android source code to your classpath and then (b) will compile but blow up when you deploy.
Be aware that you're best doing this on a Nexus branded device as this has the vanilla Android code on it. My (successful) attempt to write a home screen widget to turn tethering on and off worked on a Nexus One but did not work on a Samsung Galaxy Tab P1000. The device supported tethering, but Samsung had modified that part of the OS as part of their porting effort.

Related

Android> Creating phone app using custom code OR modifying source code for built-in native phone

I am a novice Android-Java developer and am building a custom telephony application.
From my understanding there are 2 approaches I can take.
Build a custom app from scratch using the SDK and TelephonyManager class
Or, grab the entire native app source from source.android.com and 'hack' the existing phone application.
The application MUST run in kiosk mode and also run automatically when the device is powered on, both of which I am still researching.
It will also need to communicate via the Android Open Accessory Protocol with an external arduino device (no voice data, probably just volume levels).
Can any android experts suggest which approach, 1 or 2 is going to be easiest to implement and why?
If I am not wrong than you are going to implement it using Java in that case I would suggest 3rd Option.
Option 3: Write your own wrapper on top of existing TelephonyManager and extend the feature functionality.
I am not sure how deep you are going to change the existing API but in case you are going to enhance the feature than this option seems good.

Can one access Android API in a Java Application outside Android?

I want to access Android API classes outside an Android project. For example is it possible to get an object to the Context of the device connected to a machine or the running emulator?
This will allow access to a system services like PowerManager or ActivityManager outside an Android device. If not via Context object, is there any other way to access the system services for a device/avd outside Android?
No way. Distributed android API classes are merely stubs good enough to compile against them.
Even most innocent stuff is stubbed out to throw RuntimeException on invocation. If you like to know status of the system, you will have to use SDK tools. Or write app exposing android objects via some remote access technology
I very much doubt that it is possible. The distributed SDK classes do not include many parts of the internal API. See, for example, this thread. Besides, what use would there be to have a system service object like PowerManager without a system (or an emulation of one) to back it up?
It sounds like what you're trying to do is not really access things on the device, as much as remotely control the device. In this case, there are some external tools that you should look into. The tools are mainly focused on testing, and are based on instrumentation for apps. You can look at robotium and monkeyrunner, to start with, as they provide a bit of functionality that might help you accomplish what you want. Other than that, you can also do what those tools do and write an app which listens for intents from adb, performs actions based on those intents, etc..., but you'll obviously be doing a lot of communication at a high level, so this might not be the most efficient (and I'm not sure how you'd transfer much data, which would be required for real RPC, which it sounds like you want to do).

How to programmatically create a new VPN interface with Android 4.0?

I'd like to know whether it's possible to create a VPN interface programmatically with the new VPN APIs in Android 4.0. I've looked through http://developer.android.com/resources/samples/ToyVpn but this is about creating a complete VPN client that handles the connections etc. I only want to add a new VPN configuration and possibly remove existing ones.
There are lots of questions like this but they all seem to be pre 4.0. I understand that previously this wasn't possible, but one would think that the new VPN APIs provided such functionality. So has anyone found a way to do this, or is it still not possible? If there is a way, please point me to the right direction.
It appears that this is handled internally via the com.android.settings.vpn2.VpnDialog (and related) classes, which basically do KeyStore.getInstance().put("VPN_[VPN ID]", [encoded VpnProfile object]>) -- which then causes files with names like "/data/misc/vpn/1000_VPN_[VPN ID]" to get created (where 1000 is apparently the system process ID).
Using reflection (or one of the hacks to access the hidden / internal APIs) you can do this yourself, but because your process will not be running as the system process, the system VPN browser won't see them.
However, according to this (http://code.google.com/p/android/issues/detail?id=8915), there is at least one app that does this without a rooted phone, but the source doesn't seem to be available...so perhaps there's some way to do this that I can't figure out -- I'd definitely be interested if there is.
P.S. - Here's another similar question (though it's specifically asking about using a rooted device): Create VPN profile on Android
Yes, there is a way. Use AndroidVpnService, it helps you create VPN interface on the device, there exist methods to configure that programmatically.

how can we implement CAN Application Layer(CAL) protocol in iphone/android

I need to interface a device which is supporting CANBus ,So for communication with that I need to follow CAL,So can any one help that ho can I implement
CAN Application Layer(CAL) protocol in iphone/android .
Please help i am not getting any way to solve it
"I need to interface a device which is supporting CANBus ,So for
communication with that I need to follow CAL"
The second part of that statement doesn't follow necessarily from the first. There are plenty of devices and systems that communicate via a CAN bus that don't use a formal higher level application framework.
First, you need to be able to communicate with the can bus from your application. Your mentioning iphones suggests you'll be targeting consumer handsets, none of which will have a CAN interface. So you need to incorporate some adapter hardware (there are usb adapters, and android at least has usb hardware access baked into the SDK).
If you do then also need to communicate with components that implement a higher level application framework like CANopen on top of the CAN layer, your options are:
Get your hands on the specification from whatever group maintains
it, and implement it in your language and framework of choice. This is likely a substantial effort.
Purchase or find an open source implementation. If you purchase the source code for a C implementation, you can compile it into a shared library for your target architecture, and, using android as an example, write a native wrapper for that shared library using the Android NDK to expose it to your java code. If you could purchase the source code for a java implementation, you might be able to port it so that it works natively on android.
Then you need to glue the data layer together with the application layer, and this will likely be custom development no matter what.
You need the hardware to support it. I've found Gwentech's GT1026 to work well for can bus to android, but it only works on Android using USB.

What are the key differences between Android, iOS and Blackberry OS?

What are the key differences between Android, iOS and Blackberry OS in terms of level of accessibility by application developers (i.e. access to the video input, sound input, phone functionalities, to which extent, etc.)?
PS: Assume latest version of each OS.
EDIT: Can someone turn this into a wiki so we can compile answers from people that don"t necessarily have experience in all 3 plaforms.
I'm not familiar with BlackBerry, but on Android and iOS you can access just about anything. Until recently iOS had some restrictions about camera access (see this), but I belive those have been solved. Because Android is open-source, you can theoretically go as deep as you want as far as accessing the hardware, but you may or may not be able to get any deeper through the standard Android API than you can through the iOS API.
On Android, you can do a lot more to override default functionality. For example, you can create your own launcher screen or phone application. The iOS approval process wouldn't allow these kinds of applications.
API hardware access really isn't an issue on either platform, the bigger concern is overriding default software (almost never possible in iOS) and what types of applications iOS allows.
Each platform has its own nice and bad parts. I have been working on both Android and BB. I wish I could take only nice parts from both to create a platform of a dev dream! :)
For instance, I could take these features from BB:
The greates feature I like in BB is the simplicity of the application architecture - you can always count on your main UIApplication instance - OS never kills it.
Also I do like the simplicity the Dialog class provides - it is very easy to implement business logic related to user choice - while Dialog screen is shown the code execution just stops and waits for user input.
From Android I'd take the following:
Network communication. On BB this is a real nightmare (BES, BIS, WIFI, Direct TCP without APN, Direct TCP with APN, WAP, WAP2, Unite - who's next? :)).
For file manipulations you just use a native/usual Java API.
Nice looking UI components are available right out of the box.
I should add I'm not happy with GPS related stuff on both platforms, however maybe it is due to GPS hardware limitations rather than API creators.
Thanks!
BlackBerry is a pain, once I made a project for it (the JDE version was 4.7 back then) and it didn't had an ArrayList. WTF?

Categories

Resources