What do you think about this: 1. Cursor created in onContextItemSelected() is null (for some reason) 2. Since its lifecycle is managed by the activity (startManagingCursor (c)), it tries to release it when the activity is stopped (when the new intent is launched) 3. It doesn't expect managed cursor to be null and crashes (at android.app.Activity.performStop(Activity.java:3604)) Does that make sense? I have little idea about how this cursor management works, but I would do the following: 1. Try removing startManagingCursor() calls to see if these are related 2. Double check if the cursor is null 3. Take a look inside Android source and specifically Activity.java: 3604 Just a guess :)
On Jan 5, 4:02 pm, JasonMP <hyperje...@gmail.com> wrote: > Ok, I tried gino's idea with initializing my arrays differently. I > also changed there names so that they did not share a name with any > other arrays in my app: Did not work. > > I also tried calling to static variables instead of passing variables > between classes with intents: This also did not work. > > I can't determine which line of code causes the error. The logcat > does not give me a pointer to anything in my app at all. I tried to > narrow it down with breakpoints and logging and what I found is that > it runs through all of my code without a hitch, and then once its done > it throws the exception. > > And again the exception only happens when I call the intent from a > contextMenu. > > On Jan 1, 2:56 am, Wiebbe <wie...@gmail.com> wrote: > > > > > Shouldnt you check if the bundle is null or not? Try to loop through > > it when you get there from a onContextItemSelected event. I'm guessing > > some value somewhere is null when it should be instantiated. Perhaps > > the intent is started quicker or without the bundle somehow so you get > > a nullpointer exception? > > > On 31 dec 2009, 15:57, JasonMP <hyperje...@gmail.com> wrote: > > > > yes, Select.class is another one of my files. throughout my app there > > > are a few different calls to it, all done the same way i.e. "Intent i > > > = new Intent(this, Select.class); startActivity(i);" > > > > No where in Select.class do I make a call to start Select.class or > > > Sheet.class. When its done it calls finish(); > > > > in the onCreate() of Select.class I grab the extras from the invoking > > > class with this line of code: > > > > public class Select extends ListActivity{ > > > > DBAdapter db = new DBAdapter(this); > > > String slotName = null; > > > > @Override > > > public void onCreate(Bundle savedInstanceState) { > > > super.onCreate(savedInstanceState); > > > > db.open(); > > > > ListView list = getListView(); > > > > View v = View.inflate(this, R.layout.list_header, null); > > > list.addHeaderView(v, null, false); > > > > name = > > > this.getIntent().getStringExtra(DBAdapter.KEY_NAME); > > > } > > > > Could it be something in the .getIntent() method? or > > > the .getStringExtra()? > > > > On Dec 30, 7:19 pm, "Stephen @ gmail.com" <sdickey2...@gmail.com> > > > wrote: > > > > > Now that I understand your intent creation a little better, and I see > > > > that > > > > the intent you are creating is unique from the class in which the code > > > > exists, I am not quite sure how it could be an infinite loop in the > > > > (immediate) way I was thinking. > > > > > Reading this code > > > > > Intent i = new Intent(this, Select.class); > > > > > I have to start thinking there's something wrong with this. I tried to > > > > look > > > > up the "Select" class on the android developers site, and couldn't find > > > > it. > > > > Is that a class from another of your files? I guess I would wonder if > > > > the > > > > code being invoked there, is somehow causing this class to be invoked, > > > > thus > > > > causing some kind of loop. I would grep for any reference to your Sheet > > > > class, from anywhere else in your code, and that would likely be > > > > suspect. > > > > > In general, the below is kind of a side topic, to maybe help you with > > > > generic debugging. > > > > > All the Best, Steve. > > > > > *Ok... the only thing I can think to really help you is to start taking > > > > advantage of logging. In your import list, I see you don't include the > > > > logger code, so maybe you can give this a shot. > > > > > 1) in the import list > > > > > import android.util.Log; > > > > > 2) and throughout your code > > > > > Log.d( TAG, DebugText ); > > > > > where TAG is a string that is unique to you, and "DebugText" is > > > > something > > > > useful to identify the part of the program you're interested in. > > > > > * > > > > > On Wed, Dec 30, 2009 at 11:32 AM, JasonMP <hyperje...@gmail.com> wrote: > > > > > Ok, I'm suddenly very curious by your previous statement stephen about > > > > > the possibility of creating an infinite loop. Upon a little more > > > > > investigation I'm now getting errors all over the place...same > > > > > error....just at different points in the app where I try to > > > > > startActivity(intent); As soon as the new activity receives focus is > > > > > crashes. > > > > > > On Dec 30, 1:58 pm, JasonMP <hyperje...@gmail.com> wrote: > > > > > > package com.mallet.dtool; > > > > > > > import android.app.AlertDialog; > > > > > > import android.app.TabActivity; > > > > > > import android.app.AlertDialog.Builder; > > > > > > import android.content.DialogInterface; > > > > > > import android.content.Intent; > > > > > > import android.content.DialogInterface.OnClickListener; > > > > > > import android.content.res.Configuration; > > > > > > import android.database.Cursor; > > > > > > import android.graphics.Color; > > > > > > import android.os.Bundle; > > > > > > import android.view.ContextMenu; > > > > > > import android.view.KeyEvent; > > > > > > import android.view.Menu; > > > > > > import android.view.MenuItem; > > > > > > import android.view.View; > > > > > > import android.view.ContextMenu.ContextMenuInfo; > > > > > > import android.widget.AdapterView; > > > > > > import android.widget.ImageView; > > > > > > import android.widget.LinearLayout; > > > > > > import android.widget.ListView; > > > > > > import android.widget.SimpleCursorAdapter; > > > > > > import android.widget.TabHost; > > > > > > import android.widget.TableLayout; > > > > > > import android.widget.TextView; > > > > > > import android.widget.Toast; > > > > > > import android.widget.AdapterView.AdapterContextMenuInfo; > > > > > > import android.widget.AdapterView.OnItemClickListener; > > > > > > import android.widget.TabHost.OnTabChangeListener; > > > > > > > public class Sheet extends TabActivity{ > > > > > > > @Override public void onConfigurationChanged(Configuration > > > > > newConfig) > > > > > > { super.onConfigurationChanged(newConfig); } > > > > > > DBAdapter db = new DBAdapter(this); > > > > > > static Long cRowId; > > > > > > > //Variable declaration > > > > > > > public static Integer tabState = 1; > > > > > > > @Override > > > > > > public void onCreate(Bundle savedInstanceState) { > > > > > > super.onCreate(savedInstanceState); > > > > > > setContentView(R.layout.sheet); > > > > > > > db.open(); > > > > > > > //capture Tab4 elements > > > > > > aList = (ListView) findViewById(R.id.alist); > > > > > > aList.setOnItemClickListener(new OnItemClickListener(){ > > > > > > > @Override > > > > > > public void onItemClick(AdapterView<?> > > > > > > arg0, View > > > > > arg1, int arg2, > > > > > > long arg3) { > > > > > > > Cursor c = > > > > > > db.getAll(Sheet.charName); > > > > > > > c.moveToPosition(arg2 - 1); > > > > > > > Builder builder2 = new > > > > > AlertDialog.Builder(Sheet.this); > > > > > > > > > > > > builder2.setTitle(c.getString(c.getColumnIndexOrThrow > > > > > > (DBAdapter.KEY_NAME))); > > > > > > builder2.setIcon(R.drawable.equipment); > > > > > > builder2.setMessage(c.getString(c.getColumnIndexOrThrow > > > > > > (DBAdapter.KEY_DESC))); > > > > > > builder2.setPositiveButton("Ok", null); > > > > > > builder2.show(); > > > > > > > } > > > > > > > }); > > > > > > registerForContextMenu(aList); > > > > > > > } > > > > > > @Override > > > > > > public void onResume() > > > > > > { > > > > > > super.onResume(); > > > > > > > fillAList(); > > > > > > } > > > > > > @Override > > > > > > public void onDestroy(){ > > > > > > super.onDestroy(); > > > > > > db.close(); > > > > > > } > > > > > > > @Override > > > > > > public void onCreateContextMenu(ContextMenu menu, View v, > > > > > > ContextMenuInfo menuInfo) { > > > > > > > if(v == aList){ > > > > > > menu.add(0, 7, 0, "option 1"); > > > > > > } > > > > > > } > > > > > > > @Override > > > > > > public boolean onContextItemSelected(MenuItem item) { > > > > > > AdapterContextMenuInfo info = (AdapterContextMenuInfo) > > > > > > item.getMenuInfo(); > > > > > > Cursor c = null; > > > > > > startManagingCursor(c); > > > > > > Long id; > > > > > > Integer idInt; > > > > > > > switch(item.getItemId()) { > > > > > > > case 7: > > > > > > c = db.getInfo(name); > > > > > > c.moveToPosition(info.position - 1); > > > > > > Intent i = new Intent(this, Select.class); > > > > > > i.putExtra(DBAdapter.KEY_NAME, > > > > > c.getString(c.getColumnIndexOrThrow > > > > > > (DBAdapter.KEY_NAME))); > > > > > > startActivity(i); > > > > > > > return true; > > > > > > } > > > > > > > return super.onContextItemSelected(item); > > > > > > } > > > > > > > public void fillArmorList(){ > > > > > > > Cursor c = db.getAll(Sheet.charName); > > > > > > startManagingCursor(c); > > > > > > > String[] from = new String[]{//DB columns}; > > > > > > > int[] to = new int[]{//Layout Elements}; > > > > > > > SimpleCursorAdapter items = new... > > read more »
-- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en