Log in or register to post comments

Unity 4.3, startActivity and BlackScreen

April 2, 2014 - 9:40am #1
Hi,
 
We have a strange bug on our last game and we would like to know if someone have a solution ^^.
 
So we have 2 apk able to switch from one to another with this in Unity :
try
{
    AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
    AndroidJavaObject pm = jo.Call<AndroidJavaObject>("getPackageManager");
    AndroidJavaObject intent = pm.Call<AndroidJavaObject>("getLaunchIntentForPackage", "BundleIdentifier");
    jo.Call("startActivity", intent);
}
catch (Exception e)
{
    Debug.Log ("error : " + e.Message);
    Application.OpenURL("market://details?id= BundleIdentifier");
}
With this, if there is no exception, the other app with bundle identifier equal to "BundleIdentifier" is open. Else, we go to the store to DL it.
The problem is that if one of the application change its main activity in its manifest, it can't be reopen. For example, open A, switch to B(open because never opened yet) and switch back to A. Here, when switch back to A, A is frozen on a black screen and after 1 min, the app is killed for inactivity.
 
Here is an example of a manifest with main activity changed to use Vuforia :
<activity android:name="com.qualcomm.QCARUnityPlayer.QCARPlayerNativeActivity"
  android:label="@string/app_name"
  android:screenOrientation="sensor"
  android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
  <meta-data android:name="android.app.lib_name"
    android:value="unity" />
  <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik"
    android:value="false" />
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
</activity>
We have same problem with chart boost for example because it's also change the main activity.
 
The strange thing is that if you have apk A with a custom main activity like this and B normal :
WORK : open B, B switch to A (A is opened for the first time), A switch to B, B switch to A, A switch to B...
DO NOT WORK : open A, A switch to B (B is opened for the first time), B switch to A, BLACK SCREEN.
 
It's easy to reproduce so if someone could help use please ^^.

Unity 4.3, startActivity and BlackScreen

April 7, 2014 - 12:36am #5

Indeed it's not particulary related to Vuforia but the use of Vuforia is a case where it do not work. I was hoping someone using Vuforia will have an idea to solve this problem :p

Unity 4.3, startActivity and BlackScreen

April 3, 2014 - 10:30am #4

It sounds like this issue is Android and Unity-specific and not particularly related to the Vuforia extension. Are you able to reproduce the problem with two basic Unity apk's that don't include the Vuforia components?

Unity 4.3, startActivity and BlackScreen

April 3, 2014 - 12:56am #3

I don't think I'm trying to reference the original name value.

To open another application, I use its BundleIdentifier, not an activity name. In addition, the part of the code who get the current activity is on the normal app. this activity permit to call the native methode to open another application with its BundleIdentifier.

Unity 4.3, startActivity and BlackScreen

April 2, 2014 - 1:26pm #2

It sounds like you're saying that the <activity android:name=" "> value in the manifest gets changed by Vuforia once that app is opened and that you have code that is trying to reference the original name value. Is that correct?

Log in or register to post comments