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
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?



Other Threads

1. wml focos moving in Anchor is not working


Based on the latest cupcake release(April 12, 2009), I've made wml
build enabled, and now browser can render wml file normally, but seems
wml functionality is not in full-fledge, one obvious issue is Focus
can't be moved amont anchors as it does in html pages. Does anyone
notice these?


2. pitchR PowerPoint and viewer/remote

This week I uploaded an app that does presentations, called pitchR.  I
mention this because I saw a thread where someone mentioned PowerPoint
viewer in his list of "Apps I'd like to see", and because I'd like to
get some feedback, if anyone is willing to try it out.

The vision for the app is that someone could walk into a conference
room with the presentation on their phone, and show their audience a
presentation on the big screen, initiating and controlling it from the
phone.  The screen or projector must be connected to a PC with or PowerPoint installed.  Before the presentation is
started, a Windows application called catchR is either downloaded onto
the projection PC, or catchR.exe is made available to it (on a thumb
drive, say).  The connection is over Wi-Fi.

I put catchR on my web site (, and pitchR is on
the Android Market under category Productivity.

All effects, audio, etc are shown on the big screen/speakers, and the
phone shows thumbs of each slide.  Tapping on the phone screen is like
clicking on PowerPoint - the next effect or next slide is shown.  It
also handles autorun presentations, the phone following along with the

Hope to hear that some folks have tried it out, and found it useful.
Thanks in advance for any feedback, but especially for any kind


3. Problem retrieving Draft SMS address field programmatically

4. Error when creating AVD

5. TabWidget issues

6. Eclipse and Android

7. The "-http-proxy" option does not work for emulator within 1.5r1 sdk