Display new Activity without suspending Corona Runtime (Android)

Hello!

So what I’m trying to do is to display a new activity that doesn’t take up the whole screen. However, I also want everything corona related to keep running as-is. I found that when I show the new activity, onSuspended() gets called.

Is there any way to show a new activity and keep Corona Runtime running?

Thanks,

Stiven

Can anyone from Corona help with this? It is purely the way Enterprise handles a new activity, so some input from Corona would be immensely helpful :slight_smile:

Could you actually show the code?

There is no way to prevent this via Corona Enterprise.  We’ve set up our CoronaActivity to suspend the runtime when the Activity.onPause() method gets called by the Android OS.  The onPause() method will always gets called when navigating to another activity.  That’s standard Android behavior.

   http://developer.android.com/reference/android/app/Activity.html#onPause()

If you want to display something like a “popup” without pausing the activity, then you would typically display a dialog instead.

   http://developer.android.com/guide/topics/ui/dialogs.html

And a dialog doesn’t have to be displayed like a native alert where you force the user to tap an OK/Cancel button.  You can set up the dialog to display whatever you want, because it’s just a popup container.  For example, Corona’s native activity indicator is a custom dialog that shows the standard Android spinning circle animation and nothing else.

Hi Joshua,

Thanks for your reply.

Ok, so the reason I am creating a new Activity is because I am trying to integrate a map SDK that uses GLSurfaceView. As far as I understand, Corona uses Surface View as well.
So, when I try to add the map Surface View to CoronaActivity, it does not display because you can only have one surface view.

If I display a Dialog, would the map Surface View show up? Also can I use a Fragment for that?

Thanks

You actually *can* have more than one SurfaceView displayed at the same time, such as a VideoView, but the Android OS is notoriously bugging with handling the z-order of them.  The reason is because a SurfaceView is rendered on a separate thread and is not really part of the activity’s view hierarchy.  It’s up to the Android OS’ screen compositor to try its best to rendered the SurfaceViews in the correct order onscreen.  You may want to try playing with the SurfaceView’s setZOrderMediaOverly(true) and setZOrderOnTop(true) methods to see if you can force your SurfaceView on top of Corona’s OpenGL SurfaceView.

   http://developer.android.com/reference/android/view/SurfaceView.html#setZOrderMediaOverlay(boolean

But that, you may find displaying 2 SurfaceView at the correct z-order to be unreliable on different OS versions, devices, after suspend/resume, etc.  I’ve learned to avoid it, accept that’s just how-it-is on Android, and display the other SurfaceView via a separate fullscreen activity.

Yeah, I’ve tried those methods, but they have to be called before the Surface View is attached to the Window Manager. And since the SDK creates this Surface View, I have no way of doing that.

So there’s no way I can show the map surface view on a part of the screen, and the Corona App on the other part with all parts functioning?

Honestly, I’m not sure how to do it either.  There may be a way, but it might involving a lot of trial and error.

The thing is, even if you do manage to display an activity as a dialog hosting the map surface view, you’ll still have to deal with the Android OS z-ordering issues with multiple surface view’s on the screen.  I don’t see how display a dialog works-around this.  At least if they’re both rendering at the same time.  When the Corona activity’s onPause() gets called when you display your map activity is forcing our OpenGL surface view to stop rendering, which probably prevents it from drawing on top of your map.

Can anyone from Corona help with this? It is purely the way Enterprise handles a new activity, so some input from Corona would be immensely helpful :slight_smile:

Could you actually show the code?

There is no way to prevent this via Corona Enterprise.  We’ve set up our CoronaActivity to suspend the runtime when the Activity.onPause() method gets called by the Android OS.  The onPause() method will always gets called when navigating to another activity.  That’s standard Android behavior.

   http://developer.android.com/reference/android/app/Activity.html#onPause()

If you want to display something like a “popup” without pausing the activity, then you would typically display a dialog instead.

   http://developer.android.com/guide/topics/ui/dialogs.html

And a dialog doesn’t have to be displayed like a native alert where you force the user to tap an OK/Cancel button.  You can set up the dialog to display whatever you want, because it’s just a popup container.  For example, Corona’s native activity indicator is a custom dialog that shows the standard Android spinning circle animation and nothing else.

Hi Joshua,

Thanks for your reply.

Ok, so the reason I am creating a new Activity is because I am trying to integrate a map SDK that uses GLSurfaceView. As far as I understand, Corona uses Surface View as well.
So, when I try to add the map Surface View to CoronaActivity, it does not display because you can only have one surface view.

If I display a Dialog, would the map Surface View show up? Also can I use a Fragment for that?

Thanks

You actually *can* have more than one SurfaceView displayed at the same time, such as a VideoView, but the Android OS is notoriously bugging with handling the z-order of them.  The reason is because a SurfaceView is rendered on a separate thread and is not really part of the activity’s view hierarchy.  It’s up to the Android OS’ screen compositor to try its best to rendered the SurfaceViews in the correct order onscreen.  You may want to try playing with the SurfaceView’s setZOrderMediaOverly(true) and setZOrderOnTop(true) methods to see if you can force your SurfaceView on top of Corona’s OpenGL SurfaceView.

   http://developer.android.com/reference/android/view/SurfaceView.html#setZOrderMediaOverlay(boolean

But that, you may find displaying 2 SurfaceView at the correct z-order to be unreliable on different OS versions, devices, after suspend/resume, etc.  I’ve learned to avoid it, accept that’s just how-it-is on Android, and display the other SurfaceView via a separate fullscreen activity.

Yeah, I’ve tried those methods, but they have to be called before the Surface View is attached to the Window Manager. And since the SDK creates this Surface View, I have no way of doing that.

So there’s no way I can show the map surface view on a part of the screen, and the Corona App on the other part with all parts functioning?

Honestly, I’m not sure how to do it either.  There may be a way, but it might involving a lot of trial and error.

The thing is, even if you do manage to display an activity as a dialog hosting the map surface view, you’ll still have to deal with the Android OS z-ordering issues with multiple surface view’s on the screen.  I don’t see how display a dialog works-around this.  At least if they’re both rendering at the same time.  When the Corona activity’s onPause() gets called when you display your map activity is forcing our OpenGL surface view to stop rendering, which probably prevents it from drawing on top of your map.