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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:19:02+00:00 2026-06-05T10:19:02+00:00

Hopefully there is not a lot of code, so I apologize for that. I

  • 0

Hopefully there is not a lot of code, so I apologize for that. I will try to keep it as light as possible, meaning I am not providing everything (though if needed I will). But I was debugging it, and narrowed down the issue to an intent problem in the class I am providing, but I could be wrong. My error is as follows:

6-09 00:47:15.992: E/AndroidRuntime(728): java.lang.RuntimeException: Failure delivering
result ResultInfo{who=null, request=2, result=-1, data=Intent { 
cmp=com.zeroe/.ListManagersActivity (has extras) }} to activity 
{com.zeroe/com.zeroe.MainDisplayActivity}: java.lang.ArrayIndexOutOfBoundsException:
length=2; index=2
java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
06-09 03:27:42.732: E/AndroidRuntime(5076): at
com.zeroe.SmartCalDatabaseHelper.saveManagedEvent(SmartCalDatabaseHelper.java:106)
06-09 03:27:42.732: E/AndroidRuntime(5076): at 
com.zeroe.TimeManager.insertManagedEvents(TimeManager.java:100)

So my error is in the onActivityResult() method, and I am assuming that the issue lies in the fact that it cannot access what I put into it. I am completely guessing here, but it has something to do with how the intent was created out of the scope of the class, and when the method is invoked, it can’t find it, like the intent is not for that context I guess. I have been going through it and I have nothing right now. Been at it for hours, so any hints would be greatly appreciated!

EDIT: I apologize if it wasn’t obvious, but this class was called through an intent from my main activity, and then I call another intent inside the setOnItmClickListener method. Just clarifying. And please do ask me to post anything additional if needed. I just don’t want to over bloat with code.

LATEST EDIT: Ok, so my head is killing me for looking at this for so long, but I have pin pointed exactly where the issue lies. It hangs right after it inserts the last “event” into the database in my DatabaseHelper class. I believe I have commented where that is if you can find it, but the problem, with that is I have no idea why its failing like that. I looked in my database and everything was inserted correctly!! But I believe when once its done, and it goes back to the onActivityResult, it just fails. Thats where I just can’t answer the issue. So it looks like everything is done correctly, but its the very last thing, which is the intent ending that is causing the problem? Am I missing something in my way of handling the end of the intents onActivityResult method?

DatabaseHelper.java

/*Omitting imports, but they are there*/

public class DatabaseHelper {

private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "smartcal.db";

private OpenHelper openHelper;
private SQLiteDatabase database;

public DatabaseHelper(Context context) {
    openHelper = new OpenHelper(context);
    database = openHelper.getWritableDatabase();

}

...

public Cursor getEventId(String eventName, String timeStamp) {

    return database.rawQuery("SELECT * FROM events WHERE time_stamp='"+timeStamp+"' AND event='"+eventName+"'", null);
}


public Cursor getAgendaToEdit(long id) {
    return database.rawQuery("SELECT * FROM events_info WHERE _id='"+id+"'", null);
}//end of getAgendaToEdit method


public Cursor getAgendaInfo(String date) {

    String query = "SELECT _id, event_name, start_date, start_time, end_date, end_time, " +
    "location FROM events_info WHERE date('"+date+"') >= start_date and date('"+date+"') <= end_date"; //add WHERE clause to filter for current day
    return database.rawQuery( query, null);
}//end getAgendaInfo



public Cursor getNumOfSteps(String id) {
    return database.rawQuery("SELECT _id, steps FROM managers WHERE _id='"+id+"'", null);
}

public Cursor getSteps(String id) {
    return database.rawQuery("SELECT _id, name FROM manager_steps WHERE boss='"+id+"' ORDER BY step_num", null);
}


public void saveManagedEvent(String eventId, String singleEventName, String location, String startDate, String startTime, String endDate, String endTime) {
    String[] tempDate = startDate.split("-");
    startDate = "";
    startDate = tempDate[2] + "-" + tempDate[0] + "-" + tempDate[1];
    tempDate = endDate.split("-");
    endDate = "";
    endDate = tempDate[2] + "-" + tempDate[0] + "-" + tempDate[1];

    ContentValues toSecondDatabase = new ContentValues();
    toSecondDatabase.put("event_id", eventId);
    toSecondDatabase.put("event_name", singleEventName);
    toSecondDatabase.put("start_date", startDate);
    toSecondDatabase.put("start_time", startTime);
    toSecondDatabase.put("end_date", endDate);
    toSecondDatabase.put("end_time", endTime);
    toSecondDatabase.put("location", location);
    database.insert("events_info", null, toSecondDatabase);
    /*HANGS HERE FOR SOME REASON AND GIVES ME THE ABOVE ERROR*/
}

public String saveSingleEvent(String event) {
    String timeStamp = getTimeStamp();

    ContentValues toFirstDatabase = new ContentValues();
    toFirstDatabase.put("event", event);
    toFirstDatabase.put("time_stamp", timeStamp);
    database.insert("events", null, toFirstDatabase);

    Cursor eventCursor = getEventId(event, timeStamp);
    eventCursor.moveToFirst();
    int eventId = eventCursor.getInt(0);
    eventCursor.close();
    return String.valueOf(eventId);
}


public String getTimeStamp() {
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy h:mm:ss a");
    return sdf.format(new Date());
}
private static String pad(int c) {
    if (c >= 10)
        return String.valueOf(c);
    else
        return "0" + String.valueOf(c);
}



/*SQLITEOPENHLPER INNER CLASS HERE*/


}//end of SmartCalDatabaseHelper Class

TimeManager.java

...
public void createStepsArray() {

    Cursor stepsInfo = databaseHelper.getSteps(managerId);
    for(int i=0; i < numOfSteps; i++ ) {
        stepsInfo.moveToPosition(i);
        stepHolder[i] = stepsInfo.getString(1);
    }
    stepsInfo.close();
}//end of createStepsArray method

public void insertManagedEvents() {
    Calendar now = Calendar.getInstance();
    String id = databaseHelper.saveSingleEvent(eventName);

    for(int i=0; i < numOfSteps; i++) {
        if(i == 0) now.add(Calendar.DAY_OF_MONTH, addBetweenEvents - 1); 
        else 
        now.add(Calendar.DAY_OF_MONTH, addBetweenEvents);

        if(i == numOfSteps-1) {
            databaseHelper.saveManagedEvent(id, stepHolder[i], location, 
                    new StringBuilder().append(eYear).append("-").append(pad(eMonth)).append(pad(eDay)).toString(), 
                    "00:00", 
                    new StringBuilder().append(eYear).append("-").append(pad(eMonth)).append(pad(eDay)).toString(), 
                    "00:00");
        } else { 
            databaseHelper.saveManagedEvent(id, stepHolder[i], location, 
                    new StringBuilder().append(now.get(Calendar.YEAR)).append("-").append(pad(now.get(Calendar.MONTH)+1)).append("-").append(pad(now.get(Calendar.DAY_OF_MONTH))).toString(), 
                    "00:00", 
                    new StringBuilder().append(now.get(Calendar.YEAR)).append("-").append(pad(now.get(Calendar.MONTH)+1)).append("-").append(pad(now.get(Calendar.DAY_OF_MONTH))).toString(), 
                    "00:00");
        }
    }

}//end of insertManagedEvents method

MainActivity.java

...
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == EVENT_ENTRY_REQUEST_CODE) {
        if(resultCode == RESULT_OK) {
            //send the database the info sent back from add event activity
            databaseHelper.saveSimpleEvent(data.getStringExtra("event"),data.getStringExtra("location"), 
                    data.getStringExtra("start_date"), data.getStringExtra("start_time"), 
                    data.getStringExtra("end_date"), data.getStringExtra("end_time"));

                agendaAdapter.changeCursor(databaseHelper.getAgendaInfo(getChosenDate()));

        }
    }
    if(requestCode == MANAGED_EVENT_LIST_REQUEST_CODE) {
        if(resultCode == RESULT_OK) {
            //Do stuff when managed list is working alright, and 
            //after user enters necessary info, in order to create the events into the database
            TimeManager timeManager = new TimeManager(databaseHelper, data.getStringExtra("manager_id"), 
                    data.getStringExtra("event_name"), data.getStringExtra("events_subject"), data.getStringExtra("location"), data.getStringExtra("end_time"));
            if(timeManager.checkValidManager()== false) {
                //tell user it failed due to the days not being correct in order to manage time
            } else {
                timeManager.createStepsArray();
                timeManager.insertManagedEvents();
                /*OR HANGS HERE MORE LIKELY SINCE THIS IS WHERE THE ERROR SAYS*/
            }
        }
    }
}//end of onActivityForResult 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-05T10:19:04+00:00Added an answer on June 5, 2026 at 10:19 am

    From your code I understand you are calling AddManagedEventActivity and sending extra String.valueOf(id) with tag manager_id . then in your onActivityResult you want to get data from AddManagedEventActivity ?? i think you should be using intent.getExtra(..) to get data from AddManagedEventActivity this answer is based on your code because you didnt give a short explanation of your purpose 😛 , sorry i couldnt comment, i dont have the rep :/

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

Sidebar

Related Questions

Is there any (hopefully free/open source) code available that does native TLS/SSL communication? I
Now there is a subject that could be taken many ways. Hopefully I will
Hopefully there's a solution/patch to SubSonic SimpleRepository where I can specify a column/property with
Hopefully there's a quick and dirty way to remove the Ask Question (or hide
Is there a Hibernate configuration (hopefully an annotation on a classes mapped @Column field)
Hopefully the answer is no, but are there any problems with using Request.Params instead
This post contains a lot of code, but I would really appreciate it if
I do not know a whole lot about math, so I don't know how
SubSonic is great and helps me code a lot faster, but now I've run
I see a lot of these questions asked with no answers... hopefully someone can

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.