游戏无法从其他活动启动

时间:2016-07-28 20:00:11

标签: android android-activity android-manifest google-play-games

我有一个第三方游戏应用程序,它本身可以正常工作。这是最初的AndroidManifest.xml:

<?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>

然后我添加了另一个活动MyActivity并添加了以下代码:

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

这是新的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>

当我启动新应用程序时,我遇到以下异常:

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)

我在谷歌搜索并找到了Initializing Games Client in AndroidI can't initialize Google Play game service。建议的解决方案是添加

    <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" />

到AndroidManifest.xml。我的AndroidManifest.xml中已经有这两行,但仍然有相同的异常。有谁知道这里发生了什么?谢谢!

1 个答案:

答案 0 :(得分:0)

If you try with:

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

Do you have the same result?