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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:29:10+00:00 2026-06-09T06:29:10+00:00

Still getting java.lang.StringIndexOutOfBoundsException: index=0 length=0 error in the code below at if (result.charAt(0) ==’Y’)

  • 0

Still getting java.lang.StringIndexOutOfBoundsException: index=0 length=0 error in the code below at if (result.charAt(0) =='Y')

Is there any other better way to check for null strings at if (result == null || result.isEmpty()) ? For some reason the null string “result” was not picked up or activity.finish(); did not execute and the next if statement was executed? Any help please.

@Override
    protected void onPostExecute(String result) {

        //check if result null or empty
        if (result == null || result.isEmpty()) {

            Toast.makeText(context, "Could Not Check For Updates, Please Try Again. Closing Application.", Toast.LENGTH_LONG).show();
            activity.finish();
        }           
        //update available
        if (result.charAt(0) =='Y') {

            UpdateAlert();
        }
        //no update available
        else if (result.charAt(0) =='N') {

            Toast.makeText(context, "No Updates Available", Toast.LENGTH_SHORT).show();             
        }
        else {

            Toast.makeText(context, "Could Not Check For Updates, Please Try Again. Closing Application : " + result, Toast.LENGTH_LONG).show();
            activity.finish();
        }   
  • 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-09T06:29:11+00:00Added an answer on June 9, 2026 at 6:29 am
       if (result == null || result.trim().length()==0) {
             Toast.makeText(context, "Could Not Check For Updates, Please Try Again. Closing  Application.", Toast.LENGTH_LONG).show();
                activity.finish();
            }           
            //update available
            else if (result.charAt(0) =='Y') {
            ^^^^ 
                UpdateAlert();
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting this error: Exception in thread main java.lang.OutOfMemoryError: Java heap space at
I am getting the error java.lang.IllegalStateExcepton: Failed to load Application Context when I am
I am getting this error when compiling my java program java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Then I
I am getting the 'java.lang.OutOfMemoryError: bitmap size exceeds VM budget' error... What I am
I am getting a java.lang.IllegalArgumentException similar to the link given below.To solve it I
I've come from a java background, so i'm still getting to grips with some
After resolving issues with RIA installation here , I'm still getting this following error.
Any ideas why I am getting this error? (Yes, I looked up the error,
I am getting the java.lang.SecurityException: Permission denied: file:////Videos/public/scripts/screenshot.jar when I try to use an
I'm trying to use JNI and getting java.lang.UnsatisfiedLinkError. Unlike the other million questions asked

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.