I had written certain code such that my android app should go to airplane mode and come back to connected mode with the network for around some time until i close the application forcibly. Its working with the code I had written but the problem is that the screen or display is not showing the flight symbol. When I go to settings, I can see that the code is enabling and disabling the air plane mode properly.
Can any one please give me a solution for this.
My code is as follows
public class Airplane_ModeActivity extends Activity implements Runnable{
private static final int SLEEP_TIME_VALUE = 10000;
private static Context context;
private static ContentResolver contentResolver;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
context = getApplicationContext();
contentResolver = context.getContentResolver();
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", false);
sendBroadcast(intent);
Runnable runnable = new Airplane_ModeActivity();
Thread thread = new Thread(runnable);
thread.start();
}
public void run(){
while(true) {
while(0==Settings.System.getInt(contentResolver, Settings.System.AIRPLANE_MODE_ON, 0) ) {
Settings.System.putInt(contentResolver, Settings.System.AIRPLANE_MODE_ON, 1);
try {
Thread.sleep(SLEEP_TIME_VALUE);
}
catch (InterruptedException ie) {
}
}
try {
Thread.sleep(SLEEP_TIME_VALUE);
}
catch (InterruptedException ie) {
}
while(1==Settings.System.getInt(contentResolver, Settings.System.AIRPLANE_MODE_ON, 1) ) {
Settings.System.putInt(contentResolver, Settings.System.AIRPLANE_MODE_ON, 0);
try {
Thread.sleep(SLEEP_TIME_VALUE);
}
catch (InterruptedException ie) {
}
}
try {
Thread.sleep(SLEEP_TIME_VALUE);
}
catch (InterruptedException ie) {
}
}
}
}