Same issue here. Since the return value needs to be checked against
null for Bundle.getLong(), I guess putLong() should do the same thing.
It seems to be an application logic issue, and the sample code has not
gone this far, or it may be out of scope.
On Sep 26, 10:27 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> I worked through the Notepad tutorials with the 0.9 SDK but found a
> problem with v3. Even with the "solution" project, if I initiate a new
> note, but then hit the Call or Home button on the emulator, the
> application crashes. Even after upgrading to SDK 1.0 the problem is
> still there.
>
> After debugging it seems the problem is caused by a null pointer
> exception in the onSaveInstanceState() method, when mRowId is passed
> in putLong(). Apparently "null' is not a valid value for Long?
>
> The Null value seems quite legitimate in the context, because in the
> scenario I describe, at the point of switching out of the Notepad
> application, no database entry has been created.
>
> It is only when onPause() is called that the database entry is
> created, but onSaveInstanceState() is called first and so in this
> scenario mRowId is still null.
>
> The workaround to the example is to test mRowId before writing it to
> the DB.... as in:
>
> if (mRowId != null){
> outState.putLong(NotesDbAdapter.KEY_ROWID, mRowId);
> }
>
> This works, but I can't help thinking I'm missing something. After
> searching through the logs I see no report of this problem or
> solution.
>
> It's hard to believe i'm the only one that's thought to "stress" the
> application by making a call while in the midst of writing a note! ;-)
>
> On a vaguely related note, the same tutorial references "onFreeze()",
> but it doesn't seem to be part of the Activity class. Is it a
> deprecated reference?
>
> Any insight appreciated - much thanks -
> David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---