- Home /
android: why scene goes black when showing new activity?
Hi, I am developing a plugin that allows showing a new activity on top of the existing unity activity. The new activity is a standard android activity (does not derive from unity activity, etc). The new activity is also not full screen, i.e. it is supposed to have a transparent background (showing the underlying unity scene) with a portion of the display showing some popup UI. When I run the activity code in a native android app, all is fine, I can see the underlying activity. But when I run it inside a unity app (wrapped by a plugin), the new activity popup UI shows up with black background - the underlying unity scene/activity does not show.
here is the activity definition in the manifest, as you can see it has the usual Translucent values, etc:
<activity android:configChanges="orientation|keyboardHidden" android:name="com.mycomp.MyActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
any ideas why I don't see the background?
Answer by Jamora · Aug 13, 2013 at 08:22 PM
You could try to have [Application.runInBackground][1] = true;
set in an Awake or Start method somewhere. It defaults to false and as such pauses the Unity application when it looses focus.
[1]: http://docs.unity3d.com/Documentation/ScriptReference/Application-runInBackground.html
thx you answer! I try your method, but my question don't solution!
Answer by yx.xiong · Oct 16, 2013 at 07:22 AM
Write your custom UnityProxyActivity,UnityPlayerActivity,and UnityPlayerNativeActivity 125https://developer.vuforia.com/resources/dev-guide/extending-unity-activities125, then override onPause and onResume like this:
if (myKeepRunning) {
try {
Class superSuperClass = this.getClass().getSuperclass()
.getSuperclass().getSuperclass();
Field field = null;
field = superSuperClass.getDeclaredField("mCalled");
// set accessible true
field.setAccessible(true);
field.set(this, true);
Log.v("MyUnityPlayerNativeActivity", "Value of privateKey: "
+ field.get(this));
} catch (Exception e) {
super.onPause();
}
} else {
super.onPause();
}
Answer by izowooi · Sep 30, 2014 at 01:54 AM
Try change the MainActivity. There are three Native java class in Unity3d. I changed my MainActivity. Then I solved it.
Your answer
Follow this Question
Related Questions
show Alertdialog in android 0 Answers
How can I replace correctly the main activity on the Android Manifest? 0 Answers
Android - Touch input won't work, Invisible activity in front of Unity activity 0 Answers
Android plugin & Activity help needed - "GetMethodID method not found" problems 0 Answers
How to open transparent activity from UnityPlayerActivity? 0 Answers