Unity 5.6.0b3 - Android plugin: can't show native TextView or Layout

Hello i’m trying to add a simple TextView with an Android plugin.
But I discovered that we can’t add a new native view above the UnityPlayer.currentActivity

UnityPlayer.currentActivity.addContentView > Shows the view in the background. So the native view is hidden.

I can’t set the new view on top, above the UnityPlayer.

    public static void addText2() {
        UnityPlayer.currentActivity.runOnUiThread(new Runnable()
        {
            public void run()
            {

                TextView tView = new TextView(UnityPlayer.currentActivity.getApplicationContext());
                tView.setText("TextView Programmatically AddText 2.");
                tView.setTextSize(22);
                tView.setEnabled(true);
                tView.setTextIsSelectable(true);
                tView.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
                tView.setPadding(20, 0 , 20, 0);
                tView.setTextColor(Color.parseColor("#FF0000"));
                tView.setGravity(Gravity.CENTER);
                tView.bringToFront();

                LinearLayout linearLayout = new LinearLayout(UnityPlayer.currentActivity.getApplicationContext());
                linearLayout.addView(tView);
                linearLayout.bringToFront();
                linearLayout.setGravity(Gravity.CENTER);
                linearLayout.setPadding(20 , 0, 20, 0);

                UnityPlayer.currentActivity.addContentView(linearLayout, new LayoutParams( LayoutParams.FILL_PARENT , LayoutParams.FILL_PARENT ));
            }
        });
    }

my project also have this issue, please fix as soon as possible.this is a big bug…why do i must take a huge risk of upgrading in Unity 5.x every time …Unity 5.x in Android is very unsettled …

ps. when i use Unity 5.5, this issue will not happen…so Unity 5.6 is suck…

Same problem here. This sounds bad:

Edit:
Since we’re relying on this heavily with already released products, I also submitted a detailed bug report:
https://fogbugz.unity3d.com/default.asp?902648_ds59pqgjtlmhhll9

Same for me, using 5.6. Now it is unable to add Ad Banner, because the banner is show under the unity player. ie. Hidden.!

Fullscreen ad it no problem.

This guy solved it, and confirmed it works for my other plugin as well.

“For Unity 5.6 or newer, you also need to modify android:name from com.unity3d.player.UnityPlayerActivity tonet.gree.unitywebview.CUnityPlayerActivity. This custom activity implementation will adjust Unity’s SurfaceView z order.”

I was able to do something similar by adjusting the SufaceView child of com.unity3d.player.UnityPlayer, its not pretty, but it does work without having to mess with the manifest.

unityPlayer.removeView(surfaceView);
surfaceView.setZOrderOnTop(false);
unityPlayer.addView(surfaceView);

My code finds the unityPlayer ViewGroup, finds the SurfaceView child, removes it (screen goes black), modifies the ZOrder, and then adds it back. I then add my custom Views as normal.

I’ve got more work & testing, then I’ll post some code.

Update: While the hack worked initially, the test app would quit after a varying amount of time, but not with a crash… at this point, I’m going to roll back to Unity 5.5.3

Find Unity-Admob, they have fixed this problem by using popupwindows class. I think unity are not see it is a problem.

Yeah, seems like it. My issue already was answered.

Bumb. Unity, please, fix it with upcoming patch :cry:

They won’t, at least not the way I asked for. Please read Unity’s response here:
https://fogbugz.unity3d.com/default.asp?902648_ds59pqgjtlmhhll9

Its saying Fixed in Future Release. Does it mean it got fixed?

bump! Any one from unity who can explain when it was fixed?

@Evaldas_Unity @Yury-Habets Please help.

Hi Voxel,

Yes, this issue is already fixed in 5.6.1p4 (Unity 5.6.1p4)

  • (916119) - Android: Fixed a regression where Banner Ads are invisible, but still clickable.
    You can try with this version to check if this works on your side.

Thanks for updating @zaniocz !
I will give a try today.

Also is this fix any way related to this issue and got resolved too?

You can read more on what actually happened behind the scenes with this issue at the following article Unity and Android — Connecting the dots | by Andreas Vourkos | AndroidPub | Medium

@vourkosa Thanks for sharing! Interesting read!