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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:35:31+00:00 2026-06-03T07:35:31+00:00

I have read so many articles but still don’t get it. I have a

  • 0

I have read so many articles but still don’t get it.

I have a serial data which is a String type and i want to compare it with an integer.

This is the read serial data code:

case MESSAGE_READ:
                int i;

                byte[] readBuf = (byte[]) msg.obj; 


             // construct a string from the valid bytes in the buffer
                String readMessage = new String(readBuf, 0, msg.arg1);
                Log.i(LOG_TAG, readMessage);

                mTextView.setText(readMessage);
                String [] numbers = readMessage.split("\n");
                int [] intNumber = new int[numbers.length];
                //List<Integer> integers = new ArrayList<Integer>();


                for (String number : numbers) {

                    //integers.add(Integer.valueOf(number.trim()));
                    for (i=0;i<numbers.length;i++){
                        intNumber[i] = Integer.valueOf(number.trim());
                        if (intNumber[i]<0 || intNumber[i]>95){
                            //Some Actions
                        }
                    }
                }
                break;

And the LogCat shows:

05-06 17:28:06.919: D/BluetoothReadService(15090): connected
05-06 17:28:06.919: D/BluetoothReadService(15090): create ConnectedThread
05-06 17:28:06.929: D/BluetoothReadService(15090): setState() 2 -> 3
05-06 17:28:06.949: I/BluetoothReadService(15090): BEGIN mConnectedThread
05-06 17:28:06.969: I/HBAS(15090): MESSAGE_STATE_CHANGE: 3
05-06 17:28:07.079: I/HBAS(15090): 24

05-06 17:28:07.079: I/HBAS(15090): 25

05-06 17:28:07.079: I/HBAS(15090): 26

05-06 17:28:07.079: I/HBAS(15090): 27

05-06 17:28:07.079: I/HBAS(15090): 28

05-06 17:28:07.079: I/HBAS(15090): 29

05-06 17:28:07.079: I/HBAS(15090): 0

05-06 17:28:07.079: I/HBAS(15090): 1

05-06 17:28:07.079: I/HBAS(15090): 2

05-06 17:28:07.079: I/HBAS(15090): 3

05-06 17:28:07.079: I/HBAS(15090): 4

05-06 17:28:07.079: I/HBAS(15090): 5

05-06 17:28:07.079: I/HBAS(15090): 6

05-06 17:28:07.079: I/HBAS(15090): 7

05-06 17:28:07.079: I/HBAS(15090): 8

05-06 17:28:07.079: I/HBAS(15090): 9

05-06 17:28:07.079: I/HBAS(15090): 10

05-06 17:28:07.079: I/HBAS(15090): 11

05-06 17:28:07.079: I/HBAS(15090): 12

05-06 17:28:07.079: I/HBAS(15090): 13

05-06 17:28:07.079: I/HBAS(15090): 14

05-06 17:28:07.079: I/HBAS(15090): 15

05-06 17:28:07.079: I/HBAS(15090): 16

05-06 17:28:07.079: I/HBAS(15090): 17

05-06 17:28:07.079: I/HBAS(15090): 18

05-06 17:28:07.079: I/HBAS(15090): 19

05-06 17:28:07.079: I/HBAS(15090): 20

05-06 17:28:07.079: I/HBAS(15090): 21

05-06 17:28:07.079: I/HBAS(15090): 22

05-06 17:28:07.079: I/HBAS(15090): 23

05-06 17:28:07.079: I/HBAS(15090): 24

05-06 17:28:07.079: I/HBAS(15090): 25

05-06 17:28:07.079: I/HBAS(15090): 26

05-06 17:28:07.079: I/HBAS(15090): 27

05-06 17:28:07.079: I/HBAS(15090): 28

05-06 17:28:07.079: I/HBAS(15090): 29

05-06 17:28:07.079: I/HBAS(15090): 0

05-06 17:28:07.079: I/HBAS(15090): 1

05-06 17:28:07.079: I/HBAS(15090): 2

05-06 17:28:07.079: I/HBAS(15090): 3

05-06 17:28:07.079: I/HBAS(15090): 4

05-06 17:28:07.079: I/HBAS(15090): 5

05-06 17:28:07.079: I/HBAS(15090): 6

05-06 17:28:07.079: I/HBAS(15090): 7

05-06 17:28:07.079: I/HBAS(15090): 8

05-06 17:28:07.079: I/HBAS(15090): 9

05-06 17:28:07.079: I/HBAS(15090): 10

05-06 17:28:07.079: I/HBAS(15090): 11

05-06 17:28:07.079: I/HBAS(15090): 12

05-06 17:28:07.079: I/HBAS(15090): 13

05-06 17:28:07.079: I/HBAS(15090): 14

05-06 17:28:07.079: I/HBAS(15090): 15

05-06 17:28:07.079: I/HBAS(15090): 16

05-06 17:28:07.079: I/HBAS(15090): 17

05-06 17:28:07.079: I/HBAS(15090): 18

05-06 17:28:07.079: I/HBAS(15090): 19

05-06 17:28:07.079: I/HBAS(15090): 20

05-06 17:28:07.079: I/HBAS(15090): 21

05-06 17:28:07.079: I/HBAS(15090): 22

05-06 17:28:07.079: I/HBAS(15090): 23

05-06 17:28:07.079: I/HBAS(15090): 24

05-06 17:28:07.079: I/HBAS(15090): 25

05-06 17:28:07.079: I/HBAS(15090): 26

05-06 17:28:07.079: I/HBAS(15090): 27

05-06 17:28:07.079: I/HBAS(15090): 28

05-06 17:28:07.079: I/HBAS(15090): 29

05-06 17:28:07.079: I/HBAS(15090): 0

05-06 17:28:07.079: I/HBAS(15090): 1

05-06 17:28:07.079: I/HBAS(15090): 2

05-06 17:28:07.079: I/HBAS(15090): 3

05-06 17:28:07.079: I/HBAS(15090): 4

05-06 17:28:07.079: I/HBAS(15090): 5

05-06 17:28:07.079: I/HBAS(15090): 6

05-06 17:28:07.079: I/HBAS(15090): 7

05-06 17:28:07.079: I/HBAS(15090): 8

05-06 17:28:07.079: I/HBAS(15090): 9

05-06 17:28:07.079: I/HBAS(15090): 10

05-06 17:28:07.079: I/HBAS(15090): 11

05-06 17:28:07.079: I/HBAS(15090): 12

05-06 17:28:07.079: I/HBAS(15090): 13

05-06 17:28:07.079: I/HBAS(15090): 14

05-06 17:28:07.079: I/HBAS(15090): 15

05-06 17:28:07.079: I/HBAS(15090): 16

05-06 17:28:07.079: I/HBAS(15090): 17

05-06 17:28:07.079: I/HBAS(15090): 18

05-06 17:28:07.079: I/HBAS(15090): 19

05-06 17:28:07.079: I/HBAS(15090): 20

05-06 17:28:07.079: I/HBAS(15090): 21

05-06 17:28:07.079: I/HBAS(15090): 22

05-06 17:28:07.079: I/HBAS(15090): 23

05-06 17:28:07.079: I/HBAS(15090): 24

05-06 17:28:07.079: I/HBAS(15090): 25

05-06 17:28:07.079: I/HBAS(15090): 26

05-06 17:28:07.079: I/HBAS(15090): 27

05-06 17:28:07.079: I/HBAS(15090): 28

05-06 17:28:07.079: I/HBAS(15090): 29

05-06 17:28:07.079: I/HBAS(15090): 0

05-06 17:28:07.079: I/HBAS(15090): 1

05-06 17:28:07.079: I/HBAS(15090): 2

05-06 17:28:07.079: I/HBAS(15090): 3

05-06 17:28:07.079: I/HBAS(15090): 4

05-06 17:28:07.079: I/HBAS(15090): 5

05-06 17:28:07.079: I/HBAS(15090): 6

05-06 17:28:07.079: I/HBAS(15090): 7

05-06 17:28:07.079: I/HBAS(15090): 8

05-06 17:28:07.079: I/HBAS(15090): 9

05-06 17:28:07.079: I/HBAS(15090): 10

05-06 17:28:07.079: I/HBAS(15090): 11

05-06 17:28:07.079: I/HBAS(15090): 12

05-06 17:28:07.969: I/HBAS(15090): 1
05-06 17:28:08.029: I/HBAS(15090): 3

05-06 17:28:09.019: I/HBAS(15090): 14

05-06 17:28:09.979: I/HBAS(15090): 1
05-06 17:28:10.029: I/HBAS(15090): 5

05-06 17:28:10.989: I/HBAS(15090): 16

05-06 17:28:12.009: I/HBAS(15090): 17

05-06 17:28:12.999: I/HBAS(15090): 18

05-06 17:28:13.999: I/HBAS(15090): 19

05-06 17:28:14.999: I/HBAS(15090): 20

05-06 17:28:16.009: I/HBAS(15090): 21

05-06 17:28:17.009: I/HBAS(15090): 22

05-06 17:28:18.009: I/HBAS(15090): 23

05-06 17:28:19.019: I/HBAS(15090): 24

05-06 17:28:20.019: I/HBAS(15090): 25

05-06 17:28:21.029: I/HBAS(15090): 26

05-06 17:28:22.029: I/HBAS(15090): 27

05-06 17:28:23.029: I/HBAS(15090): 28

05-06 17:28:24.039: I/HBAS(15090): 29

05-06 17:28:25.039: I/HBAS(15090): 0

05-06 17:28:26.029: I/HBAS(15090): 1
05-06 17:28:26.069: I/HBAS(15090): 

05-06 17:28:26.069: D/AndroidRuntime(15090): Shutting down VM
05-06 17:28:26.069: W/dalvikvm(15090): threadid=1: thread exiting with uncaught exception (group=0x40018578)
05-06 17:28:26.079: E/AndroidRuntime(15090): FATAL EXCEPTION: main
05-06 17:28:26.079: E/AndroidRuntime(15090): java.lang.NumberFormatException: unable to parse '' as integer
05-06 17:28:26.079: E/AndroidRuntime(15090):    at java.lang.Integer.parseInt(Integer.java:362)
05-06 17:28:26.079: E/AndroidRuntime(15090):    at java.lang.Integer.parseInt(Integer.java:332)
05-06 17:28:26.079: E/AndroidRuntime(15090):    at java.lang.Integer.valueOf(Integer.java:506)
05-06 17:28:26.079: E/AndroidRuntime(15090):    at com.android.hbas.FinalSetting$1.handleMessage(FinalSetting.java:362)
05-06 17:28:26.079: E/AndroidRuntime(15090):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-06 17:28:26.079: E/AndroidRuntime(15090):    at android.os.Looper.loop(Looper.java:130)
05-06 17:28:26.079: E/AndroidRuntime(15090):    at android.app.ActivityThread.main(ActivityThread.java:3687)
05-06 17:28:26.079: E/AndroidRuntime(15090):    at java.lang.reflect.Method.invokeNative(Native Method)
05-06 17:28:26.079: E/AndroidRuntime(15090):    at java.lang.reflect.Method.invoke(Method.java:507)
05-06 17:28:26.079: E/AndroidRuntime(15090):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
05-06 17:28:26.079: E/AndroidRuntime(15090):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
05-06 17:28:26.079: E/AndroidRuntime(15090):    at dalvik.system.NativeStart.main(Native Method)

At start it worked but at some time it FC because of ‘ ‘ thing.
So any solution???
Thanks for the advice..

  • 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-03T07:35:32+00:00Added an answer on June 3, 2026 at 7:35 am

    check your string is ' ' only.

        if(str.trim().length>0){
    
           try{ 
    
           int i =Integer.parseInt(str);
    
           }catch(NumberFormatException ne){
              System.out.println("could not parse :: " +ne);
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read many about REST api in php articles. but I still get
I dont get 1-n relationship. I have read some articles but still cant figure
I have read many articles regarding layout, but I am still quitely confused. My
I have read many questions about Android, J2ME and RecordStore , but I still
I have read many articles about vertical centering but I’m afraid not many of
I have gone through many articles but I am still not clear about the
I have read many articles about linq to sql performance. The result which i
Having read many tutorials, articles and questions, I am still have confusions about updating
I have read through many posts and articles about styling a Wordpress Gallery, but
Windows Forms and Navigation I have researched and read many different web articles and

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.