In this short video it shows how to check whether the Airplane mode of the phone is Enabled or disabled from your Android App's code (programmatically).
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: [email protected]
Complete source code and other details/ steps of this video are posted in the below link:
https://programmerworld.co/android/ho...
However, the main Java code is copied below also for reference:
package com.programmerworld.airplanemodestatuscheck;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.textView);
}
public void buttonCheckAirplaneModeStatus(View view){
if (Settings.Global.getInt(this.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, 0) != 0){
textView.setText("Airplane Mode is ON");
}
else {
textView.setText("Airplane Mode is OFF");
}
}
}
-