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);
AppContext.getInstance().getContext().sendBroadcast
(intent);
return;
}
if(!isAirplaneModeOn && status)
{
Settings.System.putInt(AppContext.getInstance().getContext
().getContentResolver(),
Settings.System.AIRPLANE_MODE_ON, 1);
AppContext.getInstance().getContext().sendBroadcast
(intent);
return;
}
}
{
return Settings.System.getInt(
(),Settings.System.AIRPLANE_
}
/**
*
* @param status
*/
public static void setAirplaneMode(Context context,boolean status)
{
if(
{
}
if(!
{
}
if(
{
().getContentResolver(),
Intent intent = new Intent
(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", 0); (Intent.ACTION_AIRPLANE_MODE_
AppContext.getInstance().
(intent);
return;
}
if(!
{
().getContentResolver(),
Intent intent = new Intent
(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", 1); (Intent.ACTION_AIRPLANE_MODE_
AppContext.getInstance().
(intent);
return;
}
}
No comments:
Post a Comment