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. How often do you read feedback on your own apps?

About the same here.  I like to keep on top of any negatives or problems
that come through so I can address them on my apps website or in the
comments themselves if the app is free.  Great way to build up reputation
with the users that way.



2. Update #4: Kloteran External Battery 4400mAh - Just Mobile Gum Pro & Gum Plu

List pemesan so far:

*Gum Plus*:
1. Fuad Jauhari
2. iki
3. Chippy
4. Indra S Adillah
5. Arimurti Pramuditta
6. Andremagis
7. Ahmad Fadlah
8. Deska Affif - *Lunas*
9.  Ronny Iskandar - *DP*
10. Maykel Herdianto - *DP*
11. Achmad A Trisatya - *DP*
12. Ketut Rutin - *Lunas*
13. Kusuma - *Lunas*
14. Jonathan
15. Jonathan
16. Geggoh Tinambunan - *DP*
17. Irsan R. - *Lunas*
18. Petrus Gunawan - *DP*
19. Bang Rachmat
20. Iyul Syaaf - *Lunas*
21. Saut Tambunan - *DP*
22. Fahruddin Arrazy
23. Albert Antonio
24. Herman Cahyadi - *Lunas*
25. iLman Ramli - *DP*
26. Anggra
27. Anggra
28. Iwan Gunawan - *DP*
29. Angga Ariansyah - *Lunas*
30. Petrus Suryadi - *DP*
31. Indra Hardani
32. Marcelinus Gozali - *DP*
33. Fahru Razi - *DP*
34. Salugu Widya Utama
35. ?

*Gum Pro*:
1. Budy Wuysang - *Lunas*
2. ?

(kalau ada salah nama atau udah bayar/DP tapi belum di list, silakan japri

Mau coba masukin battery, barangkali temen2 berminat :)

Sistemnya pre-order yah, jadi barang dipesan dulu (import), perkiraan 5-8
hari sampai di Jakarta (setelah penutupan kloteran).

Informasi produknya bisa dilihat disini:
* *Gum Plus*:
--- Produk:
--- Video:
--- Review:

* *Gum Pro*:
--- Produk:
--- Review:

Dalam reviewnya yang dipakai demo adalah iPhone, namun battery ini bisa
dipake untuk device apa saja, asalkan devicenya pake koneksi USB untuk

Harga yang ditawarkan:
- Gum Plus : *Rp 575.000,-* (harga jual diluar kloteran *700rb*)
- Gum Pro : *Rp 475.000,-*  (harga jual diluar kloteran *600rb*)

Temen2 yang berminat cukup *DP 100rb* saja, sisanya dibayarkan setelah
barang sampai di Jakarta.
Pengiriman ke pemesan setelah pembayaran lunas :)
Free ongkos kirim untuk area Jabodetabek & Bandung only (maaf ya, karena
sudah mepet hehehe...)

Untuk pembelian dengan quantity tertentu, atau pemesanan produk Just Mobile
lainnya, silakan japri aja ya :)

Yang berminat silakan japri ke: **
Kloteran ditutup hari Minggu tanggal *07 Maret 2010* (*23:59 WIB*)

Hari Senin (*08 Maret 2010*) proses importnya.

Thank you....

Deska Affif
P: 088-1100-GAYA (4292) | Y!: GadgetGaya  |  Gadget Accessories Online Store

"Indonesian Android Community [id-android]" 

3. Undangan Talk Show di Malang

4. How do I determine in code what language resources are available

5. SDK Targets Not Loading In Eclipse

6. Your Android applications can now use a reliable atomic time source...

7. Your Android applications can now use a reliable atomic time source...