So I'm amking an android app and I'm filling a ListActivity with elements from a DB, then using the onListItemClick to move to a new activity passing info based on the row the user picks. Only problem seems to be with how I'm doing the intent, causes the app to crash.
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Movie m = (Movie) this.getListAdapter().getItem(position);
long selection = m.getId();
//Toast.makeText(this, "You have chosen the movie: " + " " + selection, Toast.LENGTH_LONG).show();
Intent viewTrailer = new Intent(MainActivity.this, ViewTrailer.class);
viewTrailer.putExtra("movieId", selection);
startActivity(viewTrailer);
}
The Toast was just there for debugging purposes earlier. What should happen is that the intent gets an extra with the Id based on their selection and passes it to the next activity. The selection gets the right value, but the program crashes at the
startActivity(viewTrailer)
line, and I get an error stating: The source attachment does not contain the source for the file instrumentation.class. I doubt the problem is my sources, seeing as how I've been getting these with other files which were mere coding errors.
Also, I have updated my manifest to include the new activity. Here is the log cat
12-05 22:02:08.462: W/ActivityThread(2583): Application com.example.movies is waiting for the debugger on port 8100...
12-05 22:02:08.482: I/System.out(2583): Sending WAIT chunk
12-05 22:02:08.492: I/dalvikvm(2583): Debugger is active
12-05 22:02:08.693: I/System.out(2583): Debugger has connected
12-05 22:02:08.693: I/System.out(2583): waiting for debugger to settle...
12-05 22:02:08.902: I/System.out(2583): waiting for debugger to settle...
12-05 22:02:09.112: I/System.out(2583): waiting for debugger to settle...
12-05 22:02:09.323: I/System.out(2583): waiting for debugger to settle...
12-05 22:02:09.532: I/System.out(2583): waiting for debugger to settle...
12-05 22:02:09.738: I/System.out(2583): waiting for debugger to settle...
12-05 22:02:09.942: I/System.out(2583): waiting for debugger to settle...
12-05 22:02:10.153: I/System.out(2583): debugger has settled (1315)
12-05 22:02:10.562: D/dalvikvm(2583): GC_EXTERNAL_ALLOC freed 41K, 51% free 2667K/5379K, external 1541K/1559K, paused 128ms
12-05 22:02:11.152: D/gralloc_goldfish(2583): Emulator without GPU emulation detected.
12-05 22:02:14.639: W/dalvikvm(2583): JNI WARNING: JNI method called with exception raised
12-05 22:02:14.639: W/dalvikvm(2583): in Landroid/os/Process;.setArgV0 (Ljava/lang/String;)V (GetStringCritical)
12-05 22:02:14.639: W/dalvikvm(2583): Pending exception is:
12-05 22:02:14.639: I/dalvikvm(2583): Ljava/lang/reflect/InvocationTargetException;:
12-05 22:02:14.639: I/dalvikvm(2583): at java.lang.reflect.Method.invokeNative(Native Method)
12-05 22:02:14.639: I/dalvikvm(2583): at java.lang.reflect.Method.invoke(Method.java:507)
12-05 22:02:14.639: I/dalvikvm(2583): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-05 22:02:14.639: I/dalvikvm(2583): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-05 22:02:14.639: I/dalvikvm(2583): at dalvik.system.NativeStart.main(Native Method)
12-05 22:02:14.639: I/dalvikvm(2583): Caused by:
12-05 22:02:14.639: I/dalvikvm(2583): Landroid/content/ActivityNotFoundException;: Unable to find explicit activity class {com.example.movies/com.example.movies.ViewTrailer}; have you declared this activity in your AndroidManifest.xml?
12-05 22:02:14.639: I/dalvikvm(2583): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
12-05 22:02:14.639: I/dalvikvm(2583): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
12-05 22:02:14.639: I/dalvikvm(2583): at android.app.Activity.startActivityForResult(Activity.java:2827)
12-05 22:02:14.639: I/dalvikvm(2583): at android.app.Activity.startActivity(Activity.java:2933)
12-05 22:02:14.639: I/dalvikvm(2583): at com.example.movies.MainActivity.onListItemClick(MainActivity.java:52)
12-05 22:02:14.639: I/dalvikvm(2583): at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
12-05 22:02:14.639: I/dalvikvm(2583): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
12-05 22:02:14.639: I/dalvikvm(2583): at android.widget.ListView.performItemClick(ListView.java:3513)
12-05 22:02:14.639: I/dalvikvm(2583): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
12-05 22:02:14.639: I/dalvikvm(2583): at android.os.Handler.handleCallback(Handler.java:587)
12-05 22:02:14.639: I/dalvikvm(2583): at android.os.Handler.dispatchMessage(Handler.java:92)
12-05 22:02:14.639: I/dalvikvm(2583): at android.os.Looper.loop(Looper.java:130)
12-05 22:02:14.639: I/dalvikvm(2583): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-05 22:02:14.639: I/dalvikvm(2583): at java.lang.reflect.Method.invokeNative(Native Method)
12-05 22:02:14.639: I/dalvikvm(2583): at java.lang.reflect.Method.invoke(Method.java:507)
12-05 22:02:14.642: I/dalvikvm(2583): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-05 22:02:14.642: I/dalvikvm(2583): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-05 22:02:14.642: I/dalvikvm(2583): at dalvik.system.NativeStart.main(Native Method)
12-05 22:02:14.642: I/dalvikvm(2583): "main" prio=5 tid=1 NATIVE
12-05 22:02:14.642: I/dalvikvm(2583): | group="main" sCount=0 dsCount=0 obj=0xb60f4c38 self=0x8530e48
12-05 22:02:14.642: I/dalvikvm(2583): | sysTid=2583 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=-2145907712
12-05 22:02:14.642: I/dalvikvm(2583): at android.os.Process.setArgV0(Native Method)
12-05 22:02:14.642: I/dalvikvm(2583): at android.app.ActivityThread.main(ActivityThread.java:3668)
12-05 22:02:14.642: I/dalvikvm(2583): at java.lang.reflect.Method.invokeNative(Native Method)
12-05 22:02:14.642: I/dalvikvm(2583): at java.lang.reflect.Method.invoke(Method.java:507)
12-05 22:02:14.642: I/dalvikvm(2583): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-05 22:02:14.642: I/dalvikvm(2583): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-05 22:02:14.642: I/dalvikvm(2583): at dalvik.system.NativeStart.main(Native Method)
12-05 22:02:14.642: E/dalvikvm(2583): VM aborting
The viewTrailer doesn't have much to it so far (was trying to get it running before I did anything)
public class ViewTrailer extends Activity
{
private TextView movieNumber;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_trailer);
// movieNumber = (TextView) findViewById(R.id.movieNumber);
//
// long movieId;
//
// Bundle nameBundle = new Bundle();
// nameBundle = getIntent().getExtras();
// movieId = nameBundle.getLong("movieId");
//
// movieNumber.setText(String.valueOf(movieId));
}
}
Tried both with and without the comments but both would crash.