안녕하세요
토글버튼을 이용하여 비행모드를 켜고 끄려고 합니다.
private OnClickListener airButtonListener = new OnClickListener(){
public void onClick(View v){
ToggleButton airplaneonoff_button = (ToggleButton)findViewById(R.id.airplane);
Context context = getApplicationContext();
if(airplaneonoff_button.isChecked())
{
Settings.System.putInt(context.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON,1);
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", 1);
context.sendBroadcast(intent);
airplaneonoff_button.setText("AirPlane On");
} else {
Settings.System.putInt(context.getContentResolver(),
Settings.System.AIRPLANE_MODE_ON,0);
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", 0);
context.sendBroadcast(intent);
airplaneonoff_button.setText("AirPlane Off");
}
}
};
위의 것이 비행모드 구현 ? 누르면 켜지고 꺼지긴 합니다. 문제는
if(???????????????)
{
airplaneonoff_button.setPressed(true);
airplaneonoff_button.setChecked(true);
airplaneonoff_button.setSelected(true);
airplaneonoff_button.setText("Airplane On");}
위의 버튼과 연동을 하여야 하는데
IF안에 무엇을 넣어야지 버튼이 연동이 될런지 모르겠습니다.
조언 부탁드립니다.