Activity onPause method

by Lucius Fox » Wed, 29 Apr 2009 01:47:54 GMT


Sponsored Links
 In my Activity onPause method, how can i find out if this activity is
launched by another activity? (e.g. when user clicks menu of another
activity to launch this activity?)

Should i use the
isTaskRoot()
Return whether this activity is the root of a task.

or
isChild()
Is this activity embedded inside of another activity?

Thank you.

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



Other Threads

1. Widget Path

Hi ,


By using the getContext().getApplicationContext().getPackageCodePath
(); i am able to get the

apk path

Its giving the path like "data/app/appname.apk"
but for widget  i am not getting the path

Is widget views are  handled by some system services ?

-- 

2. Potential bug in the implementation of AppWidgets

Hi

We have discovered a potential bug in the implementation of
AppWidgets. Here is a simple reproducer.

Attached is the code for an application containing a TestActivity and
a TestWidget. TestActivity extends MapActivity and TestWidget is a
simple widget provider which updates a TextView every 2 seconds.
Now if the TestActivity is launched with no instance of TestWidget
running, it works just fine. But if the TestActivity is launched after
placing the TestWidget on the home, it results in
ClassNotFoundException. Here is what we get:

I/ActivityManager(  584): Starting activity: Intent
{ action=android.intent.action.MAIN categories=
{android.intent.category.LAUNCHER} flags=0x10200000 comp=
{com.example.test/com.example.test.TestActivity} }
W/dalvikvm( 1441): Unable to resolve superclass of Lcom/example/test/
TestActivity; (15)
W/dalvikvm( 1441): Link of class 'Lcom/example/test/TestActivity;'
failed
D/AndroidRuntime( 1441): Shutting down VM
W/dalvikvm( 1441): threadid=3: thread exiting with uncaught exception
(group=0x4000fe70)
E/AndroidRuntime( 1441): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime( 1441): java.lang.RuntimeException: Unable to
instantiate activity ComponentInfo{com.example.test/
com.example.test.TestActivity}: java.lang.ClassNotFoundException:
com.example.test.TestActivity in loader
dalvik.system.pathclassloa...@49a52110
E/AndroidRuntime( 1441):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2194)
E/AndroidRuntime( 1441):     at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2284)
E/AndroidRuntime( 1441):     at android.app.ActivityThread.access$1800
(ActivityThread.java:112)
E/AndroidRuntime( 1441):     at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:1692)
E/AndroidRuntime( 1441):     at android.os.Handler.dispatchMessage
(Handler.java:99)
E/AndroidRuntime( 1441):     at android.os.Looper.loop(Looper.java:
123)
E/AndroidRuntime( 1441):     at android.app.ActivityThread.main
(ActivityThread.java:3948)
E/AndroidRuntime( 1441):     at java.lang.reflect.Method.invokeNative
(Native Method)
E/AndroidRuntime( 1441):     at java.lang.reflect.Method.invoke
(Method.java:521)
E/AndroidRuntime( 1441):     at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/AndroidRuntime( 1441):     at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:540)
E/AndroidRuntime( 1441):     at dalvik.system.NativeStart.main(Native
Method)
E/AndroidRuntime( 1441): Caused by: java.lang.ClassNotFoundException:
com.example.test.TestActivity in loader
dalvik.system.pathclassloa...@49a52110
E/AndroidRuntime( 1441):     at dalvik.system.PathClassLoader.findClass
(PathClassLoader.java:243)
E/AndroidRuntime( 1441):     at java.lang.ClassLoader.loadClass
(ClassLoader.java:573)
E/AndroidRuntime( 1441):     at java.lang.ClassLoader.loadClass
(ClassLoader.java:532)
E/AndroidRuntime( 1441):     at android.app.Instrumentation.newActivity
(Instrumentation.java:1097)
E/AndroidRuntime( 1441):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2186)
E/AndroidRuntime( 1441):     ... 11 more

So it seems we have an inconsistency in the way the class loader works
for the same apk.

WORKS - Launch the application by itself, without invoking the Widget.
DOES NOT WORK - Create a Widget on the Home screen and then launch the
application from the launcher.

The source code for this application (http://www.yousendit.com/
download/TzY3ZGVhZy96NE4zZUE9PQ) has been attached. Hope someone from
the Android team can shed light on this behavior.

BTW, this error is seen on the 1.5r3 SDK. Not sure if this has been
addressed in 1.6 and 2.0 SDKs..

Thanks,
Himanshu.

-- 

3. My appwidget broken Donut when keyboard slide out/in

4. MapView on 1.6 very strange behaviour

5. BroadcastReciver in service

6. Application design - using threads

7. Tutorials: creating 9-patch drawables using SDK tools