how to start application in last viewed activity in previous session

by greg » Thu, 22 Apr 2010 02:30:08 GMT


Sponsored Links
 I'm writing an application consisting of several activities and, on
restarts, I'd like the application to initially display the
application's activity that was the last to display in the
application's previous session.

I save information about the last activity in SharedPreferences and
I'm trying to start that last activity with a call to
startActivity(intent) from my Application's onCreate handler.  The
problem is that if I don't set the intent's FLAG_ACTIVITY_NEW_TASK,
the result is a run-time exception message in logcat suggesting that I
should set the flag.  And if I set that intent flag, the correct
activity gets started but doesn't fully initialize resulting in null
pointer exceptions (which don't occur when I don't attempt to start
the activity from my Application class).

- - -

W/dalvikvm(  805): threadid=3: thread exiting with uncaught exception
(group=0x4000fe70)
E/AndroidRuntime(  805): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime(  805): java.lang.RuntimeException: Unable to create
application com.test.tangled.TApplication:
android.util.AndroidRuntimeException: Calling startActivity() from
outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK
flag. Is this really what you want?

- - -

Any tips on how to correctly start a particular activity from the
Application class's onCreate handler?

Thanks,
Greg

--



Other Threads

1. Android phone doesn't have any interesting feature than OS

I saw HTC dream from here:
http://www.readwriteweb.com/archives/first_android_phone_just_approved.php
It doesn't support video recording and camera really sucks (3 mpb).
I though google will make some really iPhone killer not just another
phone !!!

--~--~---------~--~----~------------~-------~--~----~

2. Segmentation fault - emulator not working

Hi ,
while running a program am getting an errror
ActivityManager: [1]   Segmentation fault

and my emulator does not work..
can any one help in this issue?


thnx


ANUR




--~--~---------~--~----~------------~-------~--~----~

3. sqlite3 not found - ???

4. can't specify SDK directory in window->preferences->android on eclipse

5. 'signature' attribute of Android Manifest no longer valid in beta SDK (v0.9)

6. KeyguardManager or KeyguardLock use

7. 'signature' attribute of Android Manifest no longer valid in beta SDK (v0.9)