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

  • Home
  • SEARCH
  • 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 7795587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:06:46+00:00 2026-06-01T23:06:46+00:00

I am trying to implement an array adapter and I am getting an error

  • 0

I am trying to implement an array adapter and I am getting an error everytime the activity starts.

here is my class and I have noted the line which causes the crash.

public class Attend extends Activity{

ListView amattendees;
ListView pmattendees;
String attendingAm[];
String attendingPm[];
JSONParser jParser = new JSONParser();
 JSONObject json_event;
 String json_name = null;
 String json_badge_id = null;
 String json_venue_id = null;
 String json_event_id = null;
 String json_id = null;
 String json_date = null;
 String json_amLesson = null;
 String json_pmLesson = null;
 String json_youtubeid = null;
 String json_lessonHTML = null;
 String json_active = null;
 String json_created = null;
 String json_attending = null;
 String json_status = null;
 String fragmented = null;
 String json_title = null;
 String json_event_description = null;

 String[] participants = null;
 String setAttending_response = "Attend";
 String scannedBar = "default";
 SharedPreferences settings;
 String json_videopath;
 String str_accesstoken;
 Context context;
 VideoView youtubeVideo;
 String sAttending = "false";
 String home_venue_long = null;
 String home_venue_lat = null;
 private static final int REQUEST_BARCODE = 0;
 double my_longitude;
 double my_latitude;
 String json_venue_distance;
 String json_nearest_venue;
 String json_nearest_venue_logo;
 String json_nearest_venue_long;
 String json_nearest_venue_lat;
 String  json_participants_arr[];


 public String[] createArrayFromJSON(JSONArray json_array_participants){
      String json_participants[] = new String[json_array_participants.length()];
      json_participants_arr = new String[json_array_participants.length()];
 for(int i = 0; i < json_participants.length; i++){
     try{
         json_participants[i] = json_array_participants.getString(i);   
         json_participants_arr[i] = json_array_participants.getString(i);  
        }
        catch(JSONException e){
         e.getStackTrace();
        }
  }
 return json_participants;
 }



 public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.attend);            

        amattendees = (ListView)findViewById(R.id.amattendees);
        pmattendees = (ListView)findViewById(R.id.pmattendees);



         try{
                //get the JSON values from the URL.
                JSONObject json = jParser.getJSONFromUrl("http://ajsonfeed.com?hi=23849348934");


               json_event = json.getJSONObject("event");
               json_name = json_event.getString("name");
               json_status = json.getString("status");
               json_badge_id =  json_event.getString("badge_id");
               json_venue_id = json_event.getString("venue_id");
               json_event_id = json_event.getString("event_id");
               json_id = json_event.getString("id");
               json_date = json_event.getString("date");
               json_amLesson = json_event.getString("amLesson");
               json_pmLesson = json_event.getString("pmLesson");
               json_youtubeid= json_event.getString("youtubeId");
               json_lessonHTML = json_event.getString("lessonHTML");
               json_active = json_event.getString("active");
               json_created = json_event.getString("created");
               json_attending = json_event.getString("attending");
               fragmented = json_event.getString("fragmented");
               JSONArray json_array_participants = json_event.getJSONArray("participants");   

               createArrayFromJSON(json_array_participants);


                }
                catch(JSONException e){
                    e.getStackTrace();
                }

this line crashes it.

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,android.R.id.text1, json_participants_arr);

.

 }






}

Error log from logcat:

04-12 16:58:32.683: E/AndroidRuntime(7920): FATAL EXCEPTION: main
04-12 16:58:32.683: E/AndroidRuntime(7920): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.jujitsu.app.com/org.jujitsu.app.com.Attend}: java.lang.NullPointerException
04-12 16:58:32.683: E/AndroidRuntime(7920):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1816)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at android.app.ActivityThread.access$1500(ActivityThread.java:132)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at android.os.Looper.loop(Looper.java:143)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at android.app.ActivityThread.main(ActivityThread.java:4196)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at java.lang.reflect.Method.invokeNative(Native Method)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at java.lang.reflect.Method.invoke(Method.java:507)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at dalvik.system.NativeStart.main(Native Method)
04-12 16:58:32.683: E/AndroidRuntime(7920): Caused by: java.lang.NullPointerException
04-12 16:58:32.683: E/AndroidRuntime(7920):     at java.util.Arrays$ArrayList.<init>(Arrays.java:47)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at java.util.Arrays.asList(Arrays.java:169)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at android.widget.ArrayAdapter.<init>(ArrayAdapter.java:138)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at org.jujitsu.app.com.Attend.onCreate(Attend.java:124)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
04-12 16:58:32.683: E/AndroidRuntime(7920):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
04-12 16:58:32.683: E/AndroidRuntime(7920):     ... 11 more
  • 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-01T23:06:48+00:00Added an answer on June 1, 2026 at 11:06 pm

    Do it like this:

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, android.R.id.text1,
                          createArrayFromJSON(json_array_participants));
    

    and move this inside json’s try block

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

Sidebar

Related Questions

I'm trying to implement a function that will read from a byte array (which
I have an array of strings and I am trying to implement a foreach
I'm trying to implement multiple spinners within one activity, which appears to be working
I am trying to implement the method below which basically populates my array with
I am trying to implement a dynamic array: template <typename Item> class Array {
Okay, I'm trying to implement a templated class of an array-based queue called Queue.
Im trying to implement a 2D array class using List of Lists. Can someone
I'm trying to determine what a value is in an array and then implement
im trying to implement a custom error page, what i want to be able
Im trying to implement an Observer/Observable pattern on an EC2 instance. I have been

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.