Conflict with activity tags on android manifest: Facebook and Google Play Games in Unity3d

不打扰是莪最后的温柔 提交于 2019-12-17 21:14:40

问题


Both Facebook and Google Play Games plugins require that I use android.intent.action.MAIN and android.intent.action.LAUNCHER in the Android Manifest. But one cancels the other. I'm new to mobile development. Is there any workaround? What can I be doing wrong?

Manifest:

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


回答1:


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.




回答2:


@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);
    **}**
  } 

If you do not do this, you must first login Facebook a more complete way.

The initial value is a null value because the session because it is.



来源:https://stackoverflow.com/questions/18970822/conflict-with-activity-tags-on-android-manifest-facebook-and-google-play-games

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!