when I tried to add some values to my List inside my onResume() method i got this error:
java.lang.RuntimeException: Unable to resume activity {.../...MainActivity}: java.lang.UnsupportedOperationException
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3096)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3127)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2482)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1345)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5415)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:725)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:615)
Caused by: java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:404)
at java.util.AbstractList.add(AbstractList.java:425)
at de.toeducate.tograde.MainActivity.onResume(MainActivity.java:151)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1258)
at android.app.Activity.performResume(Activity.java:6237) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3085)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3127)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2482)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1345)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5415)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:725)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:615)
and here is the code I wrote:
List<Integer> marks = Collections.emptyList();
for (int i = 0; i < dataBase.getDataMark().size(); i++) {
marks.add(dataBase.getDataMark().get(i).getValue());
}
What does this mean?
Collections.emptyList(); returns a List that you cannot add to (hence the UnsupportedOperationException).
Use
List<Integer> marks = new ArrayList<Integer>();
instead.
Collections.emptyList() returns an instance of AbstractList. This is meant by the line
Caused by: java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:404)
in your exception's stack trace. This said you cannot call add on your marks list as add is not implemented.
Instead instantiate marks with a class that allows for adding elements, such as ArrayList:
List<Integer> marks = new ArrayList<Integer>();
Besides ArrayList, LinkedList is another implementation of AbstractList that supports adding elements. Most typically programmers use an ArrayList.
Related
I have an array of pictures which i extract the longitude and latitude details from using exif and put them on a marker on the GPS map. Currently i am using static array which i plan to change to a dynamic array in the near future. The current code crashes my app everytime i try to set my marker, i have no idea whats wrong.
public void setMarker() {
double latitude, longitude;
String[] filepath = {"/storage/emulated/0/Pictures/CapturyGallery/CapImage1451887532716.jpg", "/storage/emulated/0/Pictures/CapturyGallery/CapImage1452411474153.jpg"};
ExifInterface intf = null;
for (int y = 0; y < filepath.length; y++) {
try {
intf = new ExifInterface(filepath[y]);
} catch (IOException e) {
e.printStackTrace();
}
if (intf != null) {
latitude = Double.parseDouble(intf.getAttribute(ExifInterface.TAG_GPS_LATITUDE));
longitude = Double.parseDouble(intf.getAttribute(ExifInterface.TAG_GPS_LONGITUDE));
LatLng latLngCurrent = new LatLng(latitude, longitude);
MarkerOptions options = new MarkerOptions()
.position(latLngCurrent)
.title("test");
mMap.addMarker(options);
}
}
}
LOGCAT
`
01-11 15:19:30.251 32226-32226/com.sp.fyp.captury E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.sp.fyp.captury, PID: 32226
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:4298)
at android.view.View.performClick(View.java:5254)
at android.view.View$PerformClick.run(View.java:21179)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6843)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.view.View$1.onClick(View.java:4293)
at android.view.View.performClick(View.java:5254)
at android.view.View$PerformClick.run(View.java:21179)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6843)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.NumberFormatException: Invalid double: "1/1,18/1,30/1"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.initialParse(StringToReal.java:164)
at java.lang.StringToReal.parseDouble(StringToReal.java:282)
at java.lang.Double.parseDouble(Double.java:301)
at com.sp.fyp.captury.GPS.setMarker(GPS.java:181)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.view.View$1.onClick(View.java:4293)
at android.view.View.performClick(View.java:5254)
at android.view.View$PerformClick.run(View.java:21179)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6843)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)`
According to the Standard Exif Tags (as defined in the Exif 2.3 standard)
The latitude/longitude is expressed as three RATIONAL values giving
the degrees, minutes, and seconds, respectively. When degrees, minutes
and seconds are expressed, the format is dd/1,mm/1,ss/1. When degrees
and minutes are used and, for example, fractions of minutes are given
up to two decimal places, the format is dd/1,mmmm/100,0/1
Thus, when you get the latitude and logitude from the ExifInterface, you are getting values like 1/1,18/1,30/1. Of course this String values cannot be converted to double using Double.parseDouble and throw a NumberFormatException.
You can take a look at How do I convert Exif long/lat to real values? to find a converter.
I am working on an application in which I am using android phone contacts in my application.So, for that first of all fetch contact details and store it into ArrayList. After that I serialized that arrayList using gson library and when I deserialize it getting error.
I have used gson-2.1.jar for serializing and deserializing contact details. I am getting following error log.
AndroidRuntime﹕ FATAL EXCEPTION: main
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 8
at com.google.gson.Gson.fromJson(Gson.java:766)
at com.google.gson.Gson.fromJson(Gson.java:721)
at com.google.gson.Gson.fromJson(Gson.java:670)
at com.google.gson.Gson.fromJson(Gson.java:642)
at com.braintechnix.autoloveapp.util.MyGson.deserializer(MyGson.java:28)
at com.braintechnix.autoloveapp.fragment.ContactListFragment.onStart(ContactListFragment.java:69)
at android.support.v4.app.Fragment.performStart(Fragment.java:1986)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1061)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1207)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1572)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:493)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 8
at com.google.gson.stream.JsonReader.expect(JsonReader.java:339)
at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:306)
at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:70)
at com.google.gson.Gson.fromJson(Gson.java:755)
at com.google.gson.Gson.fromJson(Gson.java:721)
at com.google.gson.Gson.fromJson(Gson.java:670)
at com.google.gson.Gson.fromJson(Gson.java:642)
at com.braintechnix.autoloveapp.util.MyGson.deserializer(MyGson.java:28)
at com.braintechnix.autoloveapp.fragment.ContactListFragment.onStart(ContactListFragment.java:69)
at android.support.v4.app.Fragment.performStart(Fragment.java:1986)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1061)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1207)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1572)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:493)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Following is the code which I am using:
public ArrayList<Contact> deserializer(String jsonString){
//Type collectionType = new TypeToken<Collection<Contact>>(){}.getType();
// Collection<Contact> enums = gson.fromJson(jsonString, collectionType);
Contact[] contacts = gson.fromJson(jsonString, Contact[].class);
ArrayList<Contact> contactsList = new ArrayList<Contact>();
for(int i = 0; i< contacts.length; i++){
contactsList.add(contacts[i]);
}
return contactsList;
}
it is really hard to answer without the json response you are getting but from the error you have i can tell the following code will help you
Updated the answer
public ArrayList<Contact> deserializer(String jsonString){
//Type collectionType = new TypeToken<Collection<Contact>>(){}.getType();
// Collection<Contact> enums = gson.fromJson(jsonString, collectionType);
ArrayList<Contact> contactsList = (new Gson()).fromJson(jsonString,new TypeToken<ArrayList<Contact>>() {}.getType());
return contactsList;
}
following are some example that might help you with Gson library
ExampleOne
ExampleTwo
I am trying to create same ImageView 20 times in different locations, I am using this code:
rand = new Random();
ImageView[] imageViewArray = new ImageView[20];
ArrayList<Float> xarray = new ArrayList<>();
ArrayList<Float> yarray = new ArrayList<>();
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
layoutwidth = size.x;
layoutheight = size.y;
Toast.makeText(MainActivity.this, " " + layoutwidth, Toast.LENGTH_SHORT).
show();
for (int i = 0; i < 20; i++) {
imageViewArray[i] = new ImageView(this);
imageViewArray[i].setTag(i);
imageViewArray[i].setImageResource(R.mipmap.enemy);
randx = rand.nextInt(layoutwidth + 1);
randy = rand.nextInt(layoutheight + 1);
imageViewArray[i].setX(randx);
imageViewArray[i].setY(randy);
xarray.add(imageViewArray[i].getX());
yarray.add(imageViewArray[i].getY());
rlt.addView(imageViewArray[i]);
}
Eventually, My app crashes at line rlt.addView(imageViewArray[i]); and says it is a null object, here is my logcat:
09-12 14:15:19.941 20395-20395/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: firstappdevelopment.thatdoskilledme, PID: 20395
java.lang.RuntimeException: Unable to start activity ComponentInfo{firstappdevelopment.thatdoskilledme/firstappdevelopment.thatdoskilledme.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.RelativeLayout.addView(android.view.View)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3119)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3218)
at android.app.ActivityThread.access$1000(ActivityThread.java:198)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1676)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:115)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.RelativeLayout.addView(android.view.View)' on a null object reference
at firstappdevelopment.thatdoskilledme.MainActivity.onCreate(MainActivity.java:56)
at android.app.Activity.performCreate(Activity.java:6500)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3072)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3218)
at android.app.ActivityThread.access$1000(ActivityThread.java:198)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1676)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:115)
I don't know why it returns null as I created it inside the for statement, can anyone please help me, thank you :)
make sure you declare relative layout properly.
You don't have to take array of image view because all element have same bitmap so define another xml file that contain your image view and each time add that xml layout view to relative layout !
I was trying to make a ListView of reminder notes. But when I try to save it and display it in a ListView, app crashes with this error/exception. saveNote method is called when you press save button. Any help is appreciated.
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
switch(id) {
case R.id.add_reminder : {
et = (EditText)findViewById(R.id.new_note);
et.setVisibility(View.VISIBLE);
note = et.getText().toString();
i++;
Button save_button = (Button) findViewById(R.id.button_save);
save_button.setVisibility(View.VISIBLE);
}
default : return super.onOptionsItemSelected(item);
}
}
public void saveNote(View view) {
String[] notes = new String[20];
notes[i] = note;
listView = (ListView) findViewById(R.id.list);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1,notes);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//Clicked item index
int itemPosition = position;
//Clicked item value
String itemNote = (String) listView.getItemAtPosition(position);
//Alert
Toast.makeText(getApplicationContext(), "Position :" + itemPosition + " ListItem : " + itemNote, Toast.LENGTH_LONG).show();
}
});
Logcat
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:4020)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.view.View$1.onClick(View.java:4015)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
at com.cokosofts.pramith.reminder.MainActivity.saveNote(MainActivity.java:69)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.view.View$1.onClick(View.java:4015)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
The main cause which I found from the Logs is ListView is null. Please check one more time if the listView is empty or not? Also what is notes[i] = note ??
I think in each Save button click you are finding ListView and the setting Adapter each time. This is not a good approach from my point of view. You should set the adapter very first time and next time just update your adapter data and call notifyDataSetChanged();
Debug and find out why your ListView was not found on your layout (was null).
Problem is with following line:
listView = (ListView) findViewById(R.id.list);
Please check whether your xml has ListView widget with id as 'list' .
If id is different in XML it will result in a NULL object reference. When you call
listView.setAdapter(adapter)
It will give a NULL pointer exception.
I'm running into a NullPointerException, and I can't seem to figure out why. I wouldn't say I'm that experienced in android, so it seems easy for me to get lost when debugging these... :(
I've got an Application subclass defined as follows:
public class UserData extends Application {
private String email, firstName, lastName;
public String getEmail() {
return email;
}
public void setEmail(String str) {
email = str;
}
}
In one activity (loginpage), I set the email string:
UserData user = (UserData)getApplication();
user.setEmail(results);
When I log getEmail(), I see the results in this activity just fine.
In another activity (dashboard), I get the email string as follows:
UserData user = (UserData)getApplication();
Log.d("Email: ", user.getEmail());
This time, user.getEmail() returns a nullpointer. Can someone point out why this is occurring? I've got the subclass defined in my Manifest like this:
<application
android:name=".UserData"></application>
Error Log:
-12 18:10:51.261 19471-19471/habitatfinal.habitatfinal E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: habitatfinal.habitatfinal, PID: 19471
java.lang.RuntimeException: Unable to start activity ComponentInfo{habitatfinal.habitatfinal/habitatfinal.habitatfinal.dashboard}: java.lang.NullPointerException: println needs a message
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2411)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: java.lang.NullPointerException: println needs a message
at android.util.Log.println_native(Native Method)
at android.util.Log.d(Log.java:139)
at habitatfinal.habitatfinal.dashboard.onCreate(dashboard.java:29)
at android.app.Activity.performCreate(Activity.java:5958)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:155)
at android.app.ActivityThread.main(ActivityThread.java:5696)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
I found out what was going on. The problem is onPostExecute doesn't necessarily run after the onCreate() method finishes running. Because they are two different threads, the subclass may not be initialized before the program passes the intent into the next activity.
Therefore, the variables in the object weren't set before it hit the new Activity.