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 8147957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:31:58+00:00 2026-06-06T14:31:58+00:00

Actually in my Project I want to automatically change flight mode and auto rotate

  • 0

Actually in my Project I want to automatically change flight mode and auto rotate settings, and also I tried many links in stakcoverflow, and many other sites too

and Im using that, but nothing happened in execution.

For Flight Mode

public void actFlight(int val)
{
    switch(val)
    {
        case 0:
            Log.v("Mani", "Flight 0");
            Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 1);
            break;

        case 1:
            Log.v("Mani", "Flight 1");
            Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0);
            break;

        case 2:
            Log.v("Mani", "Flight 2");
            boolean isEnabled = Settings.System.getInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1;
            // toggle airplane mode
            Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);
            break;
    }
}

the val is 0, 1 or 2

0 for switch airplane mode on
1 for switch airplane mode off
2 for switch airplane mode toggle

I used to change auto rotation settings as above, it working perfectly, But I can’t toggle airplane mode,

and I also compared many times with some other examples
no error is showing, and no change in settings… what can I do..

Note: I defined and calling this function in the SERVICE (and auto rotation too)

  • 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-06-06T14:32:00+00:00Added an answer on June 6, 2026 at 2:32 pm

    You need to send Broadcast with Intent.ACTION_AIRPLANE_MODE_CHANGED change your code as:

    boolean isEnabled = Settings.System.getInt(
                    paramContext.getContentResolver(), 
                      Settings.System.AIRPLANE_MODE_ON, 0) == 1;
            if(isEnabled==true)
            {
                Settings.System.putInt(
                        paramContext.getContentResolver(),
                      Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);
    
                // Post an intent to reload
                Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
                intent.putExtra("state", !isEnabled);
                paramContext.sendBroadcast(intent);
            }
            else
            {
                Settings.System.putInt(
                        paramContext.getContentResolver(),
                      Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);
    
                // Post an intent to reload
                Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
                intent.putExtra("state", !isEnabled);
                paramContext.sendBroadcast(intent);
            }
    

    NOTE ::-
    MAKE SURE YOU HAVE THESE PERMISSIONS IN manifest.xml :

    <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
    </manifest>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a WTL project, actually WTL 8.1 with VS2008. In many tutorials
I want to get the os version that the browser opens, actually my project
I am working on a project involving struts2 and hibernate.Actually I want to execute
I actually work on iphone project, and i want to use OAuthConsumer for the
Actually in one of my project i need to read images from remote server
I'm actually using Doctrine2 within a Zend Framework project. I'm build an API to
I am converting a makefile project into a Visual Studio VC++ project. It's actually
I am trying to troubleshoot a VB.NET project that contains UserControls (actually, several of
Despite being a Project Euler program, the following code doesn't actually concern it much.
I'm working on a little (not so little actually) project in C (ref. this

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.