安装.apk后,游戏在菜单中不可见

时间:2015-02-05 19:57:07

标签: java android unity3d

我遇到一个问题,安装后我的游戏在菜单中变得不可见。安装.apk后,OPEN按钮也会被禁用,我无法启动游戏。

我在Unity3D中制作了这个游戏。我想在我的游戏中进行深层链接,因此创建了我自己的名为MainActivity的Activity扩展了UnityPlayerActivity,并在AndroidManifest.xml文件中进行了一些更改。

MainActivity.java

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;

import com.unity3d.player.UnityPlayer;
import com.unity3d.player.UnityPlayerActivity;

public class MainActivity extends UnityPlayerActivity 
{
    @Override
    protected void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);

        Log.d("MainActivity", "onCreate called!");
    }

    @Override 
    public void startActivity(Intent intent) 
    { 
        boolean isStartActivity = true;

        Uri uri = intent.getData(); 

        if (uri != null && uri.getScheme().equals("abc")) 
        {
            isStartActivity = false;
        }

        if (isStartActivity) 
        { 
            super.startActivity(intent); 
        } 
        else 
        {
            Log.d("MainActivity", "MainActivity.startActivity() : uri = " + uri.toString());    
            UnityPlayer.UnitySendMessage("Main Menu", "JuliusReward", uri.toString());
        } 
    }
}

的AndroidManifest.xml

<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.abc.xyz">

    <supports-screens
      android:smallScreens="true"
      android:normalScreens="true"
      android:largeScreens="true"
      android:xlargeScreens="true"
      android:anyDensity="true"/>

    <!-- android:debuggable should be removed in release build -->
    <application
      android:icon="@drawable/app_icon"
      android:label="@string/app_name"
      android:debuggable="true">

      <activity android:name="com.abc.xyz.MainActivity">
          <intent-filter>
              <action android:name="android.intent.action.MAIN" />
              <category android:name="android.intent.category.LAUNCHER" />
              <category android:name="android.intent.category.DEFAULT" />
              <category android:name="android.intent.category.BROWSABLE" />

              <!-- Accepts URIs that begin with "myapp://com.example.myapp” -->
              <data android:scheme="abc" android:host="com.example.abc"/>
          </intent-filter>
    </activity>

      <activity android:name="org.onepf.openiab.UnityProxyActivity"
              android:launchMode="singleTask"
              android:label="@string/app_name"
              android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
              android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      </activity>

      <receiver android:name="com.amazon.device.iap.ResponseReceiver">
        <intent-filter>
            <action
                android:name="com.amazon.inapp.purchasing.NOTIFY"
                android:permission="com.amazon.inapp.purchasing.Permission.NOTIFY" />
        </intent-filter>
      </receiver>
    </application>

    <!--all-->
    <uses-permission android:name="android.permission.INTERNET"/>
    <!--Google Play-->
    <uses-permission android:name="com.android.vending.BILLING" />
    <!--For Tablets-->
    <uses-feature android:name="android.hardware.telephony" android:required="false" />

</manifest>

1 个答案:

答案 0 :(得分:0)

请查看此帖子Intent filter for launcher and send activity

你应该有一个

<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter>

<intent-filter> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> </intent-filter>