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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:02:31+00:00 2026-06-15T08:02:31+00:00

I’ve googled my problem and also searched here on stackoverflow for a solution, but

  • 0

I’ve googled my problem and also searched here on stackoverflow for a solution, but I couldn’t find a solution to my problem. I’m trying to implement a function which checks if the ANDROID_ID is already saved in the Apps database or if it’s not. If the Device’s ANDROID_ID is null, it creates a random UUID which is then saved in the DB. My problem is that everytime i try to parse the number from the String with “Ints.tryParse” it returns null, and then the app crashes. I’ve tried the app on two Galaxy S2’s. It crashes on one of them, but works on the other one (one with Android 4.1.2 CyanogenMod, and one Stock 4.0). It also crashes in the Emulator. BTw, I’m using the Google Guava Library for “Ints.tryParse”.

Here’s the code:

    UUID uuid;
    int finalresult = 0;
    String android_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
    Log.v(TAG, "Android ID: " + android_id);
    String androidid = CharMatcher.DIGIT.retainFrom(android_id);
    Log.v(TAG, "Int0: " + androidid);
    Integer on2 = Ints.tryParse(androidid);
    if(on2 != null) {
        if(DEBUG_STATUS == 1) {
            Log.v(TAG, "Integer is: " + Integer.toString(on2));
        }
        int times = 3;
        finalresult = on2*times;
        if(DEBUG_STATUS == 1) {
            Log.v(TAG, "Result: " + Integer.toString(finalresult));
            Log.v(TAG, "Device ID: " + android_id + Integer.toString(finalresult));
        }
    }
    else
    {   
        uuid = UUID.randomUUID();
        String uuuid = CharMatcher.DIGIT.retainFrom(uuid.toString());
        Integer randomuuid = Ints.tryParse(uuuid);

        if(randomuuid == null) {
            Log.v(TAG, "Was null again...");
        }
        if(DEBUG_STATUS == 1) {
            Log.v(TAG, "Integer null!");
            Log.v(TAG, uuuid);
            Log.v(TAG, "UUID: " + randomuuid.toString());
        }
        int times = 3;
        finalresult = randomuuid.intValue()*times;
    }

Here’s the LogCat from the emulator (Android 2.3.3):

> 12-01 16:14:22.505: V/******(410): Android ID: ea58466ebe002707 

> 12-01 16:14:51.845:V/******(410): Int0: 58466002707

> 12-01 16:14:51.865: V/******(410): Was null again...

> 12-01 16:14:51.875: V/******(410): Integer null!

> 12-01 16:14:51.875: V/******(410): 801094028350597

> 12-01 16:14:51.925: E/AndroidRuntime(410): FATAL EXCEPTION: main
> 12-01 16:14:51.925: E/AndroidRuntime(410): java.lang.RuntimeException:Unable to start activity ComponentInfo{*****/******}:
> .lang.NullPointerException 12-01 16:14:51.925:
> E/AndroidRuntime(410):    at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
> 12-01 16:14:51.925: E/AndroidRuntime(410):    at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
> 12-01 16:14:51.925: E/AndroidRuntime(410):    at
> android.app.ActivityThread.access$1500(ActivityThread.java:117) 12-01
> 16:14:51.925: E/AndroidRuntime(410):  at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
> 12-01 16:14:51.925: E/AndroidRuntime(410):    at
> android.os.Handler.dispatchMessage(Handler.java:99) 12-01
> 16:14:51.925: E/AndroidRuntime(410):  at
> android.os.Looper.loop(Looper.java:123) 12-01 16:14:51.925:
> E/AndroidRuntime(410):    at
> android.app.ActivityThread.main(ActivityThread.java:3683) 12-01
>  16:14:51.925: E/AndroidRuntime(410):     at
> java.lang.reflect.Method.invokeNative(Native Method) 12-01
> 16:14:51.925: E/AndroidRuntime(410):  at
> java.lang.reflect.Method.invoke(Method.java:507) 12-01 16:14:51.925:
> E/AndroidRuntime(410):    at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
> 12-01 16:14:51.925: E/AndroidRuntime(410):    at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 12-01
> 16:14:51.925: E/AndroidRuntime(410):  at
> dalvik.system.NativeStart.main(Native Method) 12-01 16:14:51.925:
> E/AndroidRuntime(410): Caused by: java.lang.NullPointerException 12-01
> 16:14:51.925: E/AndroidRuntime(410):  at
> com.actionbarsherlock.internal.app.ActionBarImpl.selectTab(ActionBarImpl.java:526)
> 12-01 16:14:51.925: E/AndroidRuntime(410):    at
> com.actionbarsherlock.internal.app.ActionBarImpl.addTab(ActionBarImpl.java:452)
> 12-01 16:14:51.925: E/AndroidRuntime(410):    at
> com.actionbarsherlock.internal.app.ActionBarImpl.addTab(ActionBarImpl.java:438)
> 12-01 16:14:51.925: E/AndroidRuntime(410):    at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
> 12-01 16:14:51.925: E/AndroidRuntime(410):    at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
> 12-01 16:14:51.925: E/AndroidRuntime(410):    ... 11 more

I honestly don’t know what could be wrong… As you see, the String is not empty and it actually shows the ANDROID_ID from the device.

If there’s more information you need, please tell me what you need, and I will edit the post then.

  • 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-15T08:02:32+00:00Added an answer on June 15, 2026 at 8:02 am

    Use Long (Long.parseLong()) instead of Integer, because Integer.MAX_VALUE = 2 147 483 647, but your android_id is 58 466 002 707, and UUID is 801 094 028 350 597.
    Long.MAX_VALUE is 9 223 372 036 854 775 807.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to select an H1 element which is the second-child in its group
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small

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.