Friday, May 11, 2012

[android-developers] Re: Unable to resume activity:{...} Java.lang.Nullpointer exception

hi my friend!

I have exactly the same problem, but my case is to try to run the MediaStore.ACTION_IMAGE_CAPTURE intent, the system can not resumeonActivityResult and generates the following error:
  Unable to resume activity {}: java.lang.RuntimeException: Failure Delivering ResultInforesult {who = null, request = 256, result = -1, data = Intent {act = inline-data (has extras)}} to activity

any suggestions ...

Thank you for your help. 

El domingo, 23 de marzo de 2008 19:39:56 UTC-5, Dan U. escribió:
Ok, problem solved, and it had nothing to do with startManagingCursor.
Actually I think that was sort of a byproduct of the problem.

Remove myDBHelper.close() after your fillData() call. That's what
caused it.

Now for the second problem is your SimpleCursorAdapter. You are
providing it your layout for TeaTime and the id of your TextView that
is inside that. Instead, you should be specifying a layout used for
one row in the list. That means whatever components you have in the
layout you provide to SimpleCursorAdapter will show up as an item in
the list. I went ahead and changed it to use some android defaults:

                int[] to = new int[] { android.R.id.text1 };
                ListAdapter test = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_1,
                                myTeaCursor, from, to);

On Mar 23, 5:21 pm, "Dan U." <dan.ul...@gmail.com> wrote:
> I have to admit, I don't know cursors that well, so I'm learning a bit
> here. I really think it has something to do with the call to
> startManagingCursor(myTeaCursor) that you make. I have gotten to where
> I get a SQLLiteException due I guess to some query not working.
>
> I've tried experimenting with some things in the TeaTime activity, so
> maybe you can try these as well:
>
> - Override onActivityResult and make a call to fillData()
> - Make a call to stopManagingCursor(myTeaCursor) in an overridden
> onFreeze()
>
> On Mar 23, 4:25 pm, MobileBen <benjaminspeckm...@gmail.com> wrote:
>
> > Here it is. Thank you again for your help. I appreciate that. I still
> > didn't find the solution :(
>
> > public class TeaDB {
>
> >     public static final String KEY_NAME="name";
> >     public static final String KEY_BREWTIME="brewTime";
> >     public static final String KEY_ROWID="_id";
>
> >     /**
> >      * Database creation sql statement
> >      */
> >     private static final String DATABASE_CREATE =
> >         "CREATE TABLE IF NOT EXISTS "+
> >                 "TeaTable" +
> >                 " (_id integer primary key autoincrement, name text not null,
> > brewTime integer not null);";
>
> >     private static final String DATABASE_NAME = "TeaTimeDatabase";
> >     private static final String DATABASE_TABLE = "TeaTable";
> >     private static final int DATABASE_VERSION = 2;
>
> >     private SQLiteDatabase myDb = null;
> >     private final Context mCtx;
>
> >     /**
> >      * Constructor - takes the context to allow the database to be
> > opened/created
> >      * @param ctx the Context within which to work
> >      */
> >     public TeaDB(Context ctx) {
> >         this.mCtx = ctx;
> >     }
>
> >     /**
> >      * Open the teaTable database. If it cannot be opened, try to
> > create a new instance of
> >      * the database. If it cannot be created, throw an exception to
> > signal the failure
> >      * @return this (self reference, allowing this to be chained in an
> > initialization call)
> >      * @throws SQLException if the database could be neither opened or
> > created
> >      */
> >     public TeaDB open() throws SQLException {
> >            try {
> >             myDb = mCtx.openDatabase(DATABASE_NAME, null);
> >         } catch (FileNotFoundException e) {
>
> >             try {
> >                myDb =  mCtx.createDatabase(DATABASE_NAME,
> > DATABASE_VERSION, 0,
> >                         null);
>
> >                myDb.execSQL(DATABASE_CREATE);
> >     /*            myDb.execSQL("CREATE TABLE "
> >                                         + DATABASE_TABLE
> >                                         + " (Name TEXT, brewTime INT(3));");*/
>
> >             } catch (FileNotFoundException ex1) {
> >                 throw new SQLException("Could not create database");
> >             }
> >     }
> >         return this;
> >     }
>
> >     public void close() {
> >         myDb.close();
> >     }
>
> >     /**
> >      * Create a new Tea using the name and brewTime provided. If the
> > Tea is successfully created
> >      * return the new rowId for that Tea, otherwise return a -1 to
> > indicate failure.
> >      * @param name the name of the Tea
> >      * @param brewTime the brewTime of the Tea
> >      * @return rowId or -1 if failed
> >      */
> >     public long createTea(String name, int brewTime) {
> >         ContentValues initialValues = new ContentValues();
> >         initialValues.put(KEY_NAME, name);
> >         initialValues.put(KEY_BREWTIME, brewTime);
> >         return myDb.insert(DATABASE_TABLE, null, initialValues);
> >     }
>
> >     /**
> >      * Delete the Tea with the given rowId
> >      * @param rowId id of Tea to delete
> >      * @return true if deleted, false otherwise
> >      */
> >     public boolean deleteTea(int brewTime) {
> >         return myDb.delete(DATABASE_TABLE, "brewTime" + "=" +
> > brewTime, null) > 0;
> >     }
>
> >     /**
> >      * Return a Cursor over the list of all Teas in the database
> >      * @return Cursor over all Teas
> >      */
> >     public Cursor callUpAllTeas() {
> >         return myDb.query(DATABASE_TABLE, new String[] {
> >                 KEY_ROWID, KEY_NAME, KEY_BREWTIME}, null, null, null,
> > null, null);
> >     }
>
> >     /**
> >      * Return a Cursor positioned at the Tea that matches the given
> > rowId
> >      * @param rowId id of Tea to retrieve
> >      * @return Cursor positioned to matching Tea, if found
> >      * @throws SQLException if Tea could not be found/retrieved
> >      */
> >     public Cursor catchUpTea(long rowId) throws SQLException {
> >         Cursor result = myDb.query(true, DATABASE_TABLE, new String[]
> > {
> >                 KEY_ROWID, KEY_NAME, KEY_BREWTIME}, KEY_ROWID + "=" +
> > rowId, null, null,
> >                 null, null);
> >         if ((result.count() == 0) || !result.first()) {
> >             throw new SQLException("No Tea matching ID: " + rowId);
> >         }
> >         return result;
> >     }
>
> >     /**
> >      * Update the Tea using the details provided. The Tea to be
> > updated is specified using
> >      * the rowId, and it is altered to use the Name and BrewTime
> > values passed in
> >      * @param rowId id of note to update
> >      * @param name value to set Tea name to
> >      * @param brewTime value to set Tea brewTime to
> >      * @return true if the Tea was successfully updated, false
> > otherwise
> >      */
> >     public boolean updateTea(long rowId, String name, int brewTime) {
> >         ContentValues args = new ContentValues();
> >         args.put(KEY_NAME, name);
> >         args.put(KEY_BREWTIME, brewTime);
> >         return myDb.update(DATABASE_TABLE, args, KEY_ROWID + "=" +
> > rowId, null) > 0;
> >     }
>
> > }

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate