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. fatal: The remote end hung up unexpectedly

Is there something wrong with the servers, the last 2 days I have not
been able to finish a repo sync command with out the error, fatal: The
remote end hung up unexpectedly. any help would be greatly appreciated

-- 

2. "ERROR: the user data image is used by another emulator. aborting"

Have you solved your problem?
I get the same problem, is there any solution yet?

thanks




-- 

3. How to highlight text in List

4. eclipse plugin is gone

5. Download Android source code failed

6. Emulator Problem: No emulated GSM ubuntu 9.04 x64

7. what happened to my application's statistics?