1

Facebook 和 Google Play 游戏插件都要求我在 Android Manifest 中使用 android.intent.action.MAIN 和 android.intent.action.LAUNCHER。但是一个取消另一个。我是移动开发的新手。有什么解决方法吗?我做错了什么?

显现:

<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="false" android:name="com.soomla.store.SoomlaApp">

<intent-filter>

    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />

    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />

<activity android:name="com.bfsgooglegames.GoogleGamesUnityPlayerActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">

</activity>

<activity android:name="com.bfsgooglegames.GoogleGamesUnityPlayerNativeActivity" android:label="@string/app_name" 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" />

</activity>

<activity android:name="com.facebook.LoginActivity" android:screenOrientation="landscape" android:configChanges="keyboardHidden|orientation">

</activity>

<service android:name="com.soomla.billing.BillingService" />

<receiver android:name="com.soomla.billing.BillingReceiver">

  <intent-filter>

    <action android:name="com.android.vending.billing.IN_APP_NOTIFY" />

    <action android:name="com.android.vending.billing.RESPONSE_CODE" />

    <action android:name="com.android.vending.billing.PURCHASE_STATE_CHANGED" />

  </intent-filter>

<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="\ 209458325882127" />

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

4

2 回答 2

3

Yes there is a workaround! In your main activity class in java, you can add this to the onActivityResult() method:

Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);

if you don't have access to the source of com.bfsgooglegames.GoogleGamesUnityPlayerActivity which is the main activity you are using, you can create another class that extends that one. example:

import android.content.Intent;
import android.os.Bundle;
import com.facebook.Session;

public class MyMainUnityPlayerActivity extends com.bfsgooglegames.GoogleGamesUnityPlayerActivity {
  @Override
  protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
  }

  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
  } 
}

Then in your AndroidManifest.xml, use that as your main activity.

于 2013-09-24T00:43:57.977 回答
0
@Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    **if( null != Session.getActiveSession() )**
    {   
        Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
    **}**
  } 

如果您不这样做,您必须先以更完整的方式登录 Facebook。

因为会话的初始值是空值,所以它是。

于 2014-01-01T03:22:21.263 回答