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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:07:08+00:00 2026-06-15T03:07:08+00:00

I received help from someone here a week or so ago, but there seems

  • 0

I received help from someone here a week or so ago, but there seems to still be a problem with my code. I am running Android 2.0 so I cannot use the methods to get the UI, instead I need to call the methods reflectively. Below is my code

            public ConnectThread(BluetoothDevice device, boolean secure) {
        Log.d(TAG,"here5");
        mmDevice = device;
        BluetoothSocket tmp = null;
        mSocketType = secure ? "Secure" : "Insecure";
        Log.d(TAG,"here6");
        // Get a BluetoothSocket for a connection with the
        // given BluetoothDevice

        ParcelUuid[] uuids = servicesFromDevice( mmDevice );
        Log.d( Integer.toString( uuids.length ),"here7");
        try {
            if (secure) {
                tmp = device.createRfcommSocketToServiceRecord(
                        uuids[0].getUuid());
            } else {
                tmp = device.createInsecureRfcommSocketToServiceRecord(
                        uuids[0].getUuid());
            }

I receive a NullPointerException in the very last line of code above. I’m assuming it is talking about my uuids[0].getUuid() call. The servicesFromDevice function is below…

    public ParcelUuid[] servicesFromDevice(BluetoothDevice device) {
    try {
        Class cl = Class.forName("android.bluetooth.BluetoothDevice");
        Class[] par = {};
        Method method = cl.getMethod("getUuids", par);
        Object[] args = {};
        ParcelUuid[] retval = (ParcelUuid[]) method.invoke(device, args);
        return retval;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

Here is my LogCat

06-19 13:11:07.002: D/MainMenu(13137): onActivityResult -1
06-19 13:11:07.002: D/BluetoothService(13137): connect to: 00:06:66:00:A2:11
06-19 13:11:07.002: D/BluetoothService(13137): here1
06-19 13:11:07.002: D/BluetoothService(13137): here2
06-19 13:11:07.002: D/BluetoothService(13137): here5
06-19 13:11:07.010: D/BluetoothService(13137): here6
06-19 13:11:07.017: D/AndroidRuntime(13137): Shutting down VM
06-19 13:11:07.017: W/dalvikvm(13137): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-19 13:11:07.025: E/AndroidRuntime(13137): FATAL EXCEPTION: main
06-19 13:11:07.025: E/AndroidRuntime(13137): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity {my.eti.commander/my.eti.commander.MainMenu}: java.lang.NullPointerException
06-19 13:11:07.025: E/AndroidRuntime(13137):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:2574)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at android.app.ActivityThread.access$2000(ActivityThread.java:117)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:961)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at android.os.Looper.loop(Looper.java:130)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at android.app.ActivityThread.main(ActivityThread.java:3683)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at java.lang.reflect.Method.invokeNative(Native Method)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at java.lang.reflect.Method.invoke(Method.java:507)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at dalvik.system.NativeStart.main(Native Method)
06-19 13:11:07.025: E/AndroidRuntime(13137): Caused by: java.lang.NullPointerException
06-19 13:11:07.025: E/AndroidRuntime(13137):    at my.eti.commander.BluetoothService$ConnectThread.<init>(BluetoothService.java:409)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at my.eti.commander.BluetoothService.connect(BluetoothService.java:180)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at my.eti.commander.MainMenu.onActivityResult(MainMenu.java:238)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at android.app.Activity.dispatchActivityResult(Activity.java:3908)
06-19 13:11:07.025: E/AndroidRuntime(13137):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2528)
06-19 13:11:07.025: E/AndroidRuntime(13137):    ... 11 more
  • 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-15T03:07:09+00:00Added an answer on June 15, 2026 at 3:07 am

    From @Devunwired in the comment section above……

    Have you tried using the common SPP ID that many embedded devices use, rather than trying to query the device?

    You might just luck out and have one of the embedded chips that uses this service ID:

    UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB")
    

    Setting my UUID to this service ID worked for me.

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

Sidebar

Related Questions

I hope someone here can help me see where this error is coming from.
I'm back with another Flex/Flash security question. I've already received some help from the
First, thanks for all the help I've received so far from StackOverflow. I've learned
I am really hoping someone will be able to help me here. I am
I really hope someone here can help out with this. I'm using Magento 1.6.1.0
Ok I am still having some issues with this code below. I have received
I think I'm stuck and I really hope someone can help me out here.
I am having a problem doing a simple http post request from my android
Here is code from my models.py #Models.py .... class Question(models.Model): text = models.TextField(unique=True) exam
I have some code that someone wants to put on their site. Here is

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.