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. Criteria to show up in new "Related" tab in market

I would assume that the major driver behind what shows up in the
related tab is relevance by keywords in the name and description of an
app, but does anyone know specifically any other criteria behind
this?  I have an app that I release a little over a week ago that is
not showing up in the Related tab of any similar apps nor for apps
that show up in the Related tab for mine.  And, I have a much older
app that has been released for months that shows up just where I'd
expect it to.  I don't believe it has to do with ratings and downloads
because my premium app that does show up in Related has about 1/10th
the downloads of my newer one that isn't showing up, and all of them
are 4 stars and up.  I was pretty SEO minded with the description, so
the age of the app is the only limiting factor I can think of.  Thanks!

-- 

2. Force a full screen Activity to remeasure/redraw on resume?

The app I'm working on is set to NoTitleBar and Fullscreen, and the
activities are all in landscape mode. Sometimes when I return to the
application after it has been paused, the Activity looks as if it's
shifted down to make space for the title bar. If I navigate to another
Activity or even do some action that pops up a dialog, it quickly
corrects itself - the activity jumps up to full screen and remeasures
all the child views. I would like to do something like this by default
when the Activity resumes.  Is there a method in Activity that I can
call to manually retrigger the measure/layout process and possibly
applying the NoTitleBarFullScreen theme?  And if so, are there any
possible issues with doing this manually?

-- 

3. (WTCurhat) Pusing cari gadget...

4. [WTA] samsung galaxy s vibrant

5. Mau tanya tentang Android yang entry level tapi yg lumayan bagus

6. how to change webview's transparency

7. live wallpaper write access for sdcard