[TIMOB-24427] Alloy app started from secondary activity fails horribly
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2019-01-11T03:40:33.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | activity, alloy, android |
Reporter | Michael Kazmier |
Assignee | Joshua Quick |
Created | 2017-02-21T21:02:01.000+0000 |
Updated | 2019-01-11T03:40:37.000+0000 |
Description
We have a need to utilize multiple activities within our titanium/alloy application. This is a very common paradigm for Android development. However, the basic example is not able to work properly. We have created a Stack Exchange issue (http://stackoverflow.com/questions/42376926/how-to-create-an-appcelerator-alloy-android-application-with-multiple-activities) as well as a github repo demonstrating the problem (https://github.com/DaKaZ/multiactive).
It would be possible to work around the problem IF titanium would update
Ti.Android.currentActivity.intent
if the activity is re-launched with a new intent. That way we could the information on the extra keys in the current activity.
Note, if you run on an android emulator instead of device, this additional error message is displayed: [INFO] W/System.err( 2919): java.lang.NullPointerException: Attempt to read from field 'com.android.server.am.TaskRecord com.android.server.am.ActivityRecord.task' on a null object reference
Hello, Please we need some clear instructions. I can run the app on device and click on the "Open Model" text. This opens the model window with "No message" text in the middle. Please provide clear instruction to successfully regenerate the issue.
The main instructions are in the README of the gitbub. But in trying to find a work around I found an even larger issue: the Ti.Android.currentActivity.getIntent() does NOT return the current intent. Pull the latest code, build and install the app. Then do this:
Kill the app so that it is not running in the foreground or background
issue this adb command
adb shell am start -W -a android.intent.action.VIEW -d "multiactive://blocked/testing" com.kaztopia.multiactive
You should see the app open and display in an alert "multiactive://blocked/testing"
Now issue this command:
adb shell am start -W -a android.intent.action.VIEW -d "multiactive://blocked/example" com.kaztopia.multiactive
You should see "multiactive://blocked/example" BUT you still see "multiactive://blocked/testing"
It appears that Ti is unable to pull the current intent.Hello, I was able to reproduce the behavior described in the github readme. Unfortunately the behavior according to your last comment I wasn't able to reproduce. I got "Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=multiactive://blocked/testing flg=0x10000000 pkg=com.kaztopia.multiactive VirtualScreenParam=Params{mDisplayId=-1, null, mFlags=0x00000000)} }" Am I missing something?
Hi Sharif, I just double checked - the first time I just get a '"black" screen. The second time I used the adb command I get the error message (same result though, just a black screen): {{ Mikes-MacBook-Pro:multiactive kaz$ /Users/kaz/Library/Android/sdk/platform-tools/adb shell am start -n "com.kaztopia.multiactive/.SecondActivityActivity" -a android.intent.action.VIEW -c android.intent.category.DEFAULT -e "message" "HERE_I_AM" Starting: Intent { act=android.intent.action.VIEW cat=[android.intent.category.DEFAULT] cmp=com.kaztopia.multiactive/.SecondActivityActivity (has extras) } Mikes-MacBook-Pro:multiactive kaz$ /Users/kaz/Library/Android/sdk/platform-tools/adb shell am start -n "com.kaztopia.multiactive/.SecondActivityActivity" -a android.intent.action.VIEW -c android.intent.category.DEFAULT -e "message" "HERE_I_AM" Starting: Intent { act=android.intent.action.VIEW cat=[android.intent.category.DEFAULT] cmp=com.kaztopia.multiactive/.SecondActivityActivity (has extras) } Warning: Activity not started, its current task has been brought to the front }}
Moving to TIMOB for farther process.
Today I updated https://github.com/DaKaZ/multiactive.git with this some additional information. First, regarding the second activity problem. I was able to get the error to consistently show up in logcat if you try to launch the second activity without the first activity running: Here is the error: E/TiApplication( 7151): (main) [110,246] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to resume activity {com.kaztopia.multiactive/com.kaztopia.multiactive.SecondActivityActivity}: java.lang.IllegalStateException: APSAnalytics has not been enabled. Call APSAnalytics.getInstance().enable(ctx, key, deploytype) to enable.; Titanium 6.0.2,2017/02/15 16:26,undefined E/TiApplication( 7151): java.lang.RuntimeException: Unable to resume activity {com.kaztopia.multiactive/com.kaztopia.multiactive.SecondActivityActivity}: java.lang.IllegalStateException: APSAnalytics has not been enabled. Call APSAnalytics.getInstance().enable(ctx, key, deploytype) to enable. E/TiApplication( 7151): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2951) E/TiApplication( 7151): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2982) E/TiApplication( 7151): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365) E/TiApplication( 7151): at android.app.ActivityThread.access$800(ActivityThread.java:144) E/TiApplication( 7151): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) E/TiApplication( 7151): at android.os.Handler.dispatchMessage(Handler.java:102) E/TiApplication( 7151): at android.os.Looper.loop(Looper.java:135) E/TiApplication( 7151): at android.app.ActivityThread.main(ActivityThread.java:5221) E/TiApplication( 7151): at java.lang.reflect.Method.invoke(Native Method) E/TiApplication( 7151): at java.lang.reflect.Method.invoke(Method.java:372) E/TiApplication( 7151): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) E/TiApplication( 7151): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) E/TiApplication( 7151): Caused by: java.lang.IllegalStateException: APSAnalytics has not been enabled. Call APSAnalytics.getInstance().enable(ctx, key, deploytype) to enable. E/TiApplication( 7151): at com.appcelerator.aps.APSAnalytics.throwUnlessEnabled(APSAnalytics.java:252) E/TiApplication( 7151): at com.appcelerator.aps.APSAnalytics.sendAppForegroundEvent(APSAnalytics.java:132) E/TiApplication( 7151): at org.appcelerator.titanium.TiBaseActivity.onResume(TiBaseActivity.java:1324) E/TiApplication( 7151): at org.appcelerator.titanium.TiLaunchActivity.onResume(TiLaunchActivity.java:433) E/TiApplication( 7151): at ti.modules.titanium.android.TiJSActivity.onResume(TiJSActivity.java:42) E/TiApplication( 7151): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1241) E/TiApplication( 7151): at android.app.Activity.performResume(Activity.java:6023) E/TiApplication( 7151): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2940) E/TiApplication( 7151): ... 11 more
I have the same problem. I avoided by making analytics false in tiapp.xml.
This issue has been resolved in Titanium 8.0.0. Please see: [TIMOB-26075]