0

Ich habe eine Drittanbieter-Spielanwendung, die von selbst funktioniert. Hier ist das Original AndroidManifest.xml:Spiel startet nicht von einer anderen Aktivität

<?xml version="1.0" encoding="utf-8" standalone="no"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android"  android:installLocation="preferExternal" android:theme="@android:style/Theme.NoTitleBar" package="com.thirdpartycompany.appname"> 

    ...... 

    <application android:debuggable="false" android:icon="@drawable/app_icon" android:label="@string/app_name"> 
     <activity android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:label="@string/app_name" android:launchMode="singleTask" android:name="com.abc.ThirdPartyActivity" android:screenOrientation="fullSensor"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN"/> 
       <category android:name="android.intent.category.LAUNCHER"/> 
       <category android:name="android.intent.category.LEANBACK_LAUNCHER"/> 
      </intent-filter> 

     ...... 

     </activity> 

     ...... 

     <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ 1095208937458"/> 
     <meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="\ 1095208937458"/> 

     ...... 

    </application> 

    ...... 

</manifest> 

ich dann eine andere Aktivität MyActivity hinzugefügt und fügte den folgenden Code ein:

 Intent intent = new Intent(); 
     intent.setClassName("com.thirdpartycompany.appname", "com.abc.ThirdPartyActivity"); 
     startActivityForResult(intent, 7774); 

Hier wird die neue AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="preferExternal" android:theme="@android:style/Theme.NoTitleBar" package="com.thirdpartycompany.appname"> 
    <application android:debuggable="false" android:icon="@drawable/app_icon" android:label="@string/app_name"> 
     <activity android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:label="@string/app_name" android:name="com.abc.ThirdPartyActivity" android:screenOrientation="fullSensor"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LEANBACK_LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity android:name="com.mycompany.MyActivity" android:label="@string/app_name"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ 1095208937458" /> 
     <meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="\ 1095208937458" />   
    </application>    
</manifest> 

Wenn Ich starte die neue Anwendung, ich habe die folgende Ausnahme:

FATAL EXCEPTION [main] 
Unity version  : 4.5.5f1 
Device model  : intel I861B3L2CA51 
Device fingerprint: intel/inet_alc5651_64/inet_alc5651:5.1.1/LMY47V/inet-soft0204291144:userdebug/release-keys 
- [FATAL EXCEPTION [main] 
Unity version  : 4.5.5f1 
Device model  : intel I861B3L2CA51 
Device fingerprint: intel/inet_alc5651_64/inet_alc5651:5.1.1/LMY47V/inet-soft0204291144:userdebug/release-keys 
] : java.lang.Error: FATAL EXCEPTION [main] 
Unity version  : 4.5.5f1 
Device model  : intel I861B3L2CA51 
Device fingerprint: intel/inet_alc5651_64/inet_alc5651:5.1.1/LMY47V/inet-soft0204291144:userdebug/release-keys 

Caused by: java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information. 
    at com.google.android.gms.internal.hb$h.b(Unknown Source) 
    at com.google.android.gms.internal.hb$h.d(Unknown Source) 
    at com.google.android.gms.internal.hb$b.fv(Unknown Source) 
    at com.google.android.gms.internal.hb$a.handleMessage(Unknown Source) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:135) 
    at android.app.ActivityThread.main(ActivityThread.java:5258) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 

Ich suchte auf Google und fand Initializing Games Client in Android und I can't initialize Google Play game service. Die vorgeschlagene Lösung besteht darin, die Datei

<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" /> 
    <meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="@string/app_id" /> 

an AndroidManifest.xml hinzuzufügen. Ich habe diese beiden Zeilen bereits in meiner AndroidManifest.xml, habe aber immer noch dieselbe Ausnahme. Weiß jemand, was hier passiert ist? Vielen Dank!

+0

In Ihrem Manifest haben Sie hinzugefügt: "com.mycompany.MyActivity" .. Es sollte nicht "com.thirdpartycompany.MyActivity" sein? Ist der Paketname korrekt? – W0rmH0le

+0

"com.mycompany.MyActivity", "com.abc.ThirdPartyActivity" und "com.thirdpartycompany.appname" sind in Ordnung. Das Problem könnte mit dem Google Play Game-Dienst zusammenhängen, aber die ursprüngliche Anwendung funktioniert gut. – user3869992

Antwort

0

Wenn Sie versuchen, mit:

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.thirdpartycompany.appname"); 
if (launchIntent != null) { 
    startActivity(launchIntent); 
} 

Haben Sie das gleiche Ergebnis?

+0

Wenn ich das versuche, wird MyActivity anstelle von com.abc.ThirdPartyActivity gestartet? Ich muss com.abc.ThirdPartyActivity innerhalb von MyActivity starten. – user3869992

+0

Oh ja, tut mir leid. Es wird die Aktivität gestartet, die in AndroidManifest.xml deklariert wurde. – jos

+0

Ich habe das gefunden, aber ich versuche es nie. Also, froh, wenn Sie schreiben, wenn es funktioniert! :) Absicht intent = new Intent(); intent.setComponent (neuer ComponentName ("com.thirdpartycompany.appname", "com.abc.ThirdPartyActivity")); startActivity (Absicht); – jos