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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:45:35+00:00 2026-06-14T05:45:35+00:00

So I am comparing my current location with one I stored in my database.Everything

  • 0

So I am comparing my current location with one I stored in my database.Everything is going fine but I am not able to make my cell on silent when I send location using emulator control.Logcat is saying that cursor is OutOfBounds

Here’s my code

                            Cursor cur=null;
            cur=y.rawQuery("SELECT longitude FROM data",null);
            cur.moveToFirst();
            cr=y.rawQuery("SELECT latitude FROM data",null);
            cr.moveToFirst();
            while(!cr.isAfterLast()) {

                arlist.add(cr.getDouble(cr.getColumnIndex("latitude")));
                cr.moveToNext();
                }
            while(!cur.isAfterLast()) {

                arrylist.add(cr.getDouble(cr.getColumnIndex("longitude")));
                cur.moveToNext();
                }
            for(int i=0;i<arlist.size();i++){
                Location locB = new Location("point B");
                locB.setLatitude(arlist.get(i));
                locB.setLongitude(arrylist.get(i));
                float distance=loc.distanceTo(locB);
                if(distance<5){
                    ((AudioManager) getSystemService(AUDIO_SERVICE))
                      .setRingerMode(AudioManager.RINGER_MODE_SILENT);
                }
                else{
                    ((AudioManager) getSystemService(AUDIO_SERVICE))
                      .setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
                }

            }

Here’s my logcat

11-11 09:45:16.528: E/AndroidRuntime(692): FATAL EXCEPTION: main
11-11 09:45:16.528: E/AndroidRuntime(692): android.database.CursorIndexOutOfBoundsException: Index 20 requested, with a size of 20
11-11 09:45:16.528: E/AndroidRuntime(692):  at android.database.AbstractCursor.checkPosition(AbstractCursor.java:418)
11-11 09:45:16.528: E/AndroidRuntime(692):  at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
11-11 09:45:16.528: E/AndroidRuntime(692):  at android.database.AbstractWindowedCursor.getDouble(AbstractWindowedCursor.java:86)
11-11 09:45:16.528: E/AndroidRuntime(692):  at com.example.alert.service$MyLocationListener.onLocationChanged(service.java:90)
11-11 09:45:16.528: E/AndroidRuntime(692):  at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:237)
11-11 09:45:16.528: E/AndroidRuntime(692):  at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:170)
11-11 09:45:16.528: E/AndroidRuntime(692):  at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:186)
11-11 09:45:16.528: E/AndroidRuntime(692):  at  android.os.Handler.dispatchMessage(Handler.java:99)
11-11 09:45:16.528: E/AndroidRuntime(692):  at android.os.Looper.loop(Looper.java:137)
11-11 09:45:16.528: E/AndroidRuntime(692):  at android.app.ActivityThread.main(ActivityThread.java:4745)
11-11 09:45:16.528: E/AndroidRuntime(692):  at java.lang.reflect.Method.invokeNative(Native Method)
11-11 09:45:16.528: E/AndroidRuntime(692):  at java.lang.reflect.Method.invoke(Method.java:511)
11-11 09:45:16.528: E/AndroidRuntime(692):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-11 09:45:16.528: E/AndroidRuntime(692):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-11 09:45:16.528: E/AndroidRuntime(692):  at dalvik.system.NativeStart.main(Native Method)
  • 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-14T05:45:36+00:00Added an answer on June 14, 2026 at 5:45 am

    I think the problem is in this loop, where you are looping against cur but trying to retrieve from cr:

    while(!cur.isAfterLast()) {
        arrylist.add(cr.getDouble(cr.getColumnIndex("longitude")));
        cur.moveToNext();
    }
    

    It should probably be:

    while(!cur.isAfterLast()) {
        arrylist.add(cur.getDouble(cur.getColumnIndex("longitude")));
        cur.moveToNext();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My current code is pretty quick, but I need to make it even faster
I was recently comparing the current version of json2.js with the version I had
I've got my current location lat long and I've got a list of places
I'm try to access a database which was working fine (until i added more
I would like to format a gridview based on comparing the current row value
I'm creating an application which needs to determine if my current location (recd in
Hi iam using the following code for comparing the entered date with current date...
I have the php code below comparing two times against the current time using
In this plugin: http://dansnetwork.com/2010/03/27/content-expirator-jquery-content-expiration-plugin/ He is comparing the expire date d to the current
I am comparing strings from a text file, but for some reason they never

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.