Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7620683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:59:45+00:00 2026-05-31T03:59:45+00:00

I am making an app in which I want to display a pop up

  • 0

I am making an app in which I want to display a pop up if airplane mode is active but when I use the following code, it switches my app to the airplane mode means my device goes to airplane mode. Where as I want if airplane mode is active, a device should give a pop-up only. My code is as follows:

public void airplane() {
    final boolean isEnabled = Settings.System.getInt(
              getContentResolver(), 
              Settings.System.AIRPLANE_MODE_ON, 1) == 0;

        // toggle airplane mode
        Settings.System.putInt(
              getContentResolver(),
              Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0: 1);


        // Post an intent to reload
    //  Toast tt=Toast.makeText(getApplicationContext(), "Your phone is in airplane mode", Toast.LENGTH_SHORT);
    //  tt.show();
        Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
        intent.putExtra("state", isEnabled);
        sendBroadcast(intent);

        IntentFilter intentFilter = new IntentFilter("android.intent.action.SERVICE_STATE");

        BroadcastReceiver receiver = new BroadcastReceiver() {
              @Override
              public void onReceive(Context context, Intent intent) {
                    Log.d("AirplaneMode", "Service state changed");
              }
        };

        context.registerReceiver(receiver, intentFilter);

   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:59:46+00:00Added an answer on May 31, 2026 at 3:59 am

    At a guess I’d say your issue lies in the fact your integer to boolean code is incorrect.

    Try:

    final boolean isEnabled = (Settings.System.getInt(
                  getContentResolver(), 
                  Settings.System.AIRPLANE_MODE_ON, 1)) != 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i m making APP which do image proceesing using java SE.i want to check
I am making an app in which on one of the view I want
I am making an android app in which i want to make a dynamic
I am making an app in which I want to get the call logs
I am making an app in which I want to move the row.So I
I am making an app which contains fragments within tabs.In this whenever I try
I am Getting a weird problem. I am making an App which should run
I am making an app in which i need to implement calling emergency medical
I'm making an app in which I open a BrowserField and the user can
I am making an app in which I have to open default audio player.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.