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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:13:37+00:00 2026-06-15T01:13:37+00:00

I have to write an application that would work as ‘Device Hardware Admin’. The

  • 0

I have to write an application that would work as ‘Device Hardware Admin’. The user should be able to enable or disable any feature of hardware according to his preferences. I am adding the screenshot of application UI below:

Application UI

These settings are stored in a local database of application. What I have managed to do is as follows:

Step 1: I have registered broadcast receiver for detecting all these actions.

<receiver android:name=".HardwareActionListener" >
    <intent-filter>
        <action android:name="android.intent.action.CAMERA_BUTTON" >
        </action>

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.media.action.STILL_IMAGE_CAMERA" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.hardware.action.NEW_PICTURE" >
        </action>
    </intent-filter>
    <intent-filter>
        <action android:name="android.media.action.IMAGE_CAPTURE" />

        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.UMS_CONNECTED" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.UMS_DISCONNECTED" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" >
        </action>
    </intent-filter>
    <intent-filter>
        <action android:name="android.net.wifi.WIFI_STATE_CHANGED" >
        </action>
    </intent-filter>
    <intent-filter>
        <action android:name="android.net.wifi.WIFI_STATE_CHANGED_ACTION" >
        </action>
    </intent-filter>
    <intent-filter>
        <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />

            <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
    </intent-filter>
</receiver>

I am getting broadcasts for Wifi and bluetooth properly. I am not getting broadcasts on Camera action or USB connection and disconnection.

Question 1: Is anything wrong in intent filters I have used for Camera and USB detection?

Step 2: I want to block the user from using these hardwares. I managed to disable bluetooth or wifi just after user started it by detecting the action in my receiver class’s onReceive() method.

if (intent.getAction().equalsIgnoreCase(
                "android.bluetooth.adapter.action.STATE_CHANGED")) {

    int extraBTState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE,
                    BluetoothAdapter.ERROR);
    switch (extraBTState) {
        case BluetoothAdapter.STATE_CONNECTING:
            BluetoothAdapter mBluetoothAdapter = BluetoothAdapter
                        .getDefaultAdapter();
            mBluetoothAdapter.disable();
        break;
        case BluetoothAdapter.STATE_ON:

            BluetoothAdapter mBluetoothAdapter1 = BluetoothAdapter
                        .getDefaultAdapter();
            mBluetoothAdapter1.disable();
        break;
        case BluetoothAdapter.STATE_CONNECTED:

            BluetoothAdapter mBluetoothAdapter2 = BluetoothAdapter
                        .getDefaultAdapter();
            mBluetoothAdapter2.disable();
        break;
        case BluetoothAdapter.STATE_OFF:
            Toast.makeText(context, "Bluetooth access not allowed",
                        Toast.LENGTH_SHORT).show();
        break;
    }

} else if (intent.getAction().equalsIgnoreCase(
                "android.net.wifi.WIFI_STATE_CHANGED")) {
    int extraWifiState = intent.getIntExtra(
                    WifiManager.EXTRA_WIFI_STATE,
                    WifiManager.WIFI_STATE_UNKNOWN);
    switch (extraWifiState) {
        case WifiManager.WIFI_STATE_DISABLED:
            Toast.makeText(context, "Wifi enabling not allowed",
                        Toast.LENGTH_SHORT).show();
        break;

        case WifiManager.WIFI_STATE_ENABLED:

            WifiManager wifiManager1 = (WifiManager) context
                        .getSystemService(Context.WIFI_SERVICE);
            wifiManager1.setWifiEnabled(false);
        break;
        case WifiManager.WIFI_STATE_ENABLING:

            WifiManager wifiManager2 = (WifiManager) context
                        .getSystemService(Context.WIFI_SERVICE);
            wifiManager2.setWifiEnabled(false);
        break;

    }

} 

So it detects that Bluetooth or WiFi is turned on or connected and turns it off or disconnects it programmatically.

But requirement is that user shouldn’t be able to start Bluetooth or WiFi at all. That means disable the button of WiFi and Bluetooth.

Question 2: Is that possible?

Any help or suggestions would be appreciated.

  • 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-15T01:13:39+00:00Added an answer on June 15, 2026 at 1:13 am

    Relevant APIs are available for android-14 and higher: http://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#setCameraDisabled(android.content.ComponentName, boolean)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to write an application that implements a secure connection between client and
I have to write a C++ application that reads from the serial port byte
I have to write a C# application that works with a SQL server database
I have been asked to write an application that is going to act as
I have to write a SNMP module which monitor a certain server application that
I have an application that write data in the programdata folder in vista. The
I have to write an application where I retrieve a lotto numbers that I
Problem I have a UDPlistener application that I need to write a unit test
I have WPF C# application that communicate with a PLC (i.e. write/read Omron PLC's
I have a need to write a GTK application in C that does some

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.