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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:16:57+00:00 2026-06-10T19:16:57+00:00

i wrote a java file, and i get an error at line :blutooth_enabled_flag= mBluetoothAdapter.isEnabled();

  • 0

i wrote a java file, and i get an error at line :”blutooth_enabled_flag= mBluetoothAdapter.isEnabled();”

and i dont find the problem…when i run this app, i get “Unfortunately Application has stopped”

please help me find the problem

package com.example.fast.battery.charger;

import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.view.View.OnClickListener;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.SeekBar;


public class Fast_Charger extends Activity implements OnClickListener {

    Button Onbutton,Offbutton,prefbutton;
    BluetoothAdapter mBluetoothAdapter;
    WifiManager wifi;
    SeekBar brightbar;
    int bluetooth_state;
    Boolean wifi_enable_flag;
    Boolean blutooth_enabled_flag;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fast__charger);
        Onbutton= (Button)findViewById(R.id.Onbutton);
        Offbutton= (Button)findViewById(R.id.Offbutton);
        prefbutton = (Button)findViewById(R.id.prefbutton);
        mBluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
        wifi=(WifiManager)getSystemService(Context.WIFI_SERVICE); 
        blutooth_enabled_flag= mBluetoothAdapter.isEnabled();

      //  wifi_enable_flag=wifi.isWifiEnabled();
     //   Onbutton.setOnClickListener(this);
     //   Offbutton.setOnClickListener(this);
     //   prefbutton.setOnClickListener(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_fast__charger, menu);
        return true;
    }

    public void onClick(View src) {
    //  switch (src.getId()) {
    //  case R.id.Onbutton:
    //      mBluetoothAdapter.disable(); 
    //      wifi.setWifiEnabled(Boolean.TRUE);
    //      break;
    //  case R.id.Offbutton:
    //      if (bluetooth_state==BluetoothAdapter.STATE_ON) {
    //          mBluetoothAdapter.enable();
    //      }
    //      if(wifi_enable_flag==Boolean.TRUE) {
    //          wifi.setWifiEnabled(Boolean.FALSE);
    //      }
    //      break;
    //  case R.id.Brightbar:
    //      break;
    //  case R.id.prefbutton:
    //      break;
        }

    }

and this is the manifest file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.fast.charger"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk

        android:minSdkVersion="10"
        android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Fast_Charger"
            android:label="@string/title_activity_fast__charger" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
        <uses-permission android:name="android.permission.BLUETOOTH"></uses-permission>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"></uses-permission>
<uses-permission android:name="com.example.bluetooth.PERMISSION"></uses-permission>
<uses-feature android:name="android.hardware.wifi" />
</manifest>

and here is the logcat:

09-03 10:07:07.701: I/dalvikvm(537): threadid=3: reacting to signal 3
09-03 10:07:07.721: I/dalvikvm(537): Wrote stack traces to '/data/anr/traces.txt'
09-03 10:07:08.221: I/dalvikvm(537): threadid=3: reacting to signal 3
09-03 10:07:08.261: I/dalvikvm(537): Wrote stack traces to '/data/anr/traces.txt'
09-03 10:07:08.442: D/AndroidRuntime(537): Shutting down VM
09-03 10:07:08.442: W/dalvikvm(537): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
09-03 10:07:08.451: E/AndroidRuntime(537): FATAL EXCEPTION: main
09-03 10:07:08.451: E/AndroidRuntime(537): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.fast.charger/com.example.fast.charger.Fast_Charger}: java.lang.NullPointerException
09-03 10:07:08.451: E/AndroidRuntime(537):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
09-03 10:07:08.451: E/AndroidRuntime(537):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
09-03 10:07:08.451: E/AndroidRuntime(537):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
09-03 10:07:08.451: E/AndroidRuntime(537):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
09-03 10:07:08.451: E/AndroidRuntime(537):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-03 10:07:08.451: E/AndroidRuntime(537):  at android.os.Looper.loop(Looper.java:137)
09-03 10:07:08.451: E/AndroidRuntime(537):  at android.app.ActivityThread.main(ActivityThread.java:4424)
09-03 10:07:08.451: E/AndroidRuntime(537):  at java.lang.reflect.Method.invokeNative(Native Method)
09-03 10:07:08.451: E/AndroidRuntime(537):  at java.lang.reflect.Method.invoke(Method.java:511)
09-03 10:07:08.451: E/AndroidRuntime(537):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-03 10:07:08.451: E/AndroidRuntime(537):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-03 10:07:08.451: E/AndroidRuntime(537):  at dalvik.system.NativeStart.main(Native Method)
09-03 10:07:08.451: E/AndroidRuntime(537): Caused by: java.lang.NullPointerException
09-03 10:07:08.451: E/AndroidRuntime(537):  at com.example.fast.charger.Fast_Charger.onCreate(Fast_Charger.java:33)
09-03 10:07:08.451: E/AndroidRuntime(537):  at android.app.Activity.performCreate(Activity.java:4465)
09-03 10:07:08.451: E/AndroidRuntime(537):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-03 10:07:08.451: E/AndroidRuntime(537):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
09-03 10:07:08.451: E/AndroidRuntime(537):  ... 11 more
09-03 10:07:08.731: I/dalvikvm(537): threadid=3: reacting to signal 3
09-03 10:07:08.821: I/dalvikvm(537): Wrote stack traces to '/data/anr/traces.txt'
09-03 10:07:09.102: I/dalvikvm(537): threadid=3: reacting to signal 3
09-03 10:07:09.111: I/dalvikvm(537): Wrote stack traces to '/data/anr/traces.txt'
  • 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-10T19:16:58+00:00Added an answer on June 10, 2026 at 7:16 pm

    i think you are trying to run your app in emulator, since emulator doesn’t support bluetooth

     mBluetoothAdapter=BluetoothAdapter.getDefaultAdapter();
    

    mBluetoothAdapter is coming out to be null.
    Run this app on your bluetooth enabled droid and i think it will work fine.

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

Sidebar

Related Questions

This is the line I run: AudioInputStream clip1 = AudioSystem.getAudioInputStream(new File(wavFile1)); This is the
I am working on this code, and inside my first .java file I get
When I run ant debug from the command line, I get the following error
I wrote some code to read a file in my Java Servlet class. (I'm
Data comes in by email as a zipped file. The Java solution we wrote
I managed to get this code to compile with out error. But somehow it
I'm running into trouble with this basic, unsophisticated Web Server I wrote in Java.
I wrote a simple JsonParser code in java. I downloaded json jar file following
I am trying to run a java program on my AIX server. I wrote
This example demonstrates using Scanner to read a file line by line (it does

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.