Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the Network Operator with an Android App

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.

like image 464
sgalenski Avatar asked May 12 '11 10:05

sgalenski


People also ask

How do I manually select a network on Android?

Press the settings icon. Press Connections. Press Mobile networks. Press Network operators.

How do I connect my android to a local network?

3. Tap the "Settings" button on your Android device. Tap the "Wireless and Networks" option. Tap "Wi-Fi Settings" and select a Wi-Fi hotspot name to connect.

How do Android apps connect to the Internet?

Before starting your application, Android studio will display following window to select an option where you want to run your Android application. Now just click on button, It will check internet connection as well as it will download image. Out would be as follows and it has fetch the logo from internet.


1 Answers

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.

like image 68
Phil Haigh Avatar answered Sep 30 '22 05:09

Phil Haigh