[android-beginners] Re: How to set airplane mode on/off.
You shouldn't. Changing such a setting is the user's responsibility. JBQ On Sun, Jan 18, 2009 at 10:02 PM, Naeem naimidr...@gmail.com wrote: Hi All, I want to switch on/off airplane mode programmatically. How can I do this. Anybody can help me. Thaks -- Jean-Baptiste M. JBQ Queru Android Engineer, Google. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Beginners group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---
[android-beginners] Re: How to set airplane mode on/off.
Seems reasonable enough that one could write a different interface for changing this setting. Rings Extended is a great example of such an improvement. I suggest checking out the android source and seeing how this is done in the settings app. For instance, in packages/apps/ Settings/src/com/android/settings/AirplaneModeEnabler.java , this is done with the following code: Settings.System.putInt(mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, enabling ? 1 : 0); Intent intent = new Intent (Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra(state, enabling); mContext.sendBroadcast(intent); This would most certainly require to add security requirements to the AndroidManifest of your app. I'm not 100% certain that this possible to do even with the proper security flags, and I agree that you shouldn't do this without specific action by the user, as it affects system elements outside of your particular app. -Steve On Jan 19, 5:29 am, Jean-Baptiste Queru j...@google.com wrote: You shouldn't. Changing such a setting is the user's responsibility. JBQ On Sun, Jan 18, 2009 at 10:02 PM, Naeem naimidr...@gmail.com wrote: Hi All, I want to switch on/off airplane mode programmatically. How can I do this. Anybody can help me. Thaks -- Jean-Baptiste M. JBQ Queru Android Engineer, Google. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Beginners group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---
[android-beginners] Re: How to set airplane mode on/off.
Thank u so much Levis. This source code is working. public static boolean isAirplaneModeOn(Context context) { return Settings.System.getInt(context.getContentResolver (),Settings.System.AIRPLANE_MODE_ON, 0) != 0; } /** * * @param status */ public static void setAirplaneMode(Context context,boolean status) { boolean isAirplaneModeOn = isAirplaneModeOn(context); if(isAirplaneModeOn status) { return; } if(!isAirplaneModeOn !status) { return; } if(isAirplaneModeOn !status) { Settings.System.putInt(AppContext.getInstance().getContext ().getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0); Intent intent = new Intent (Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra(state, 0); AppContext.getInstance().getContext().sendBroadcast (intent); return; } if(!isAirplaneModeOn status) { Settings.System.putInt(AppContext.getInstance().getContext ().getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 1); Intent intent = new Intent (Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra(state, 1); AppContext.getInstance().getContext().sendBroadcast (intent); return; } } Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Beginners group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~--~~~~--~~--~--~---