Home » Java » java – How to start an Unity App with an Intent from another App?-Exceptionshub

java – How to start an Unity App with an Intent from another App?-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I tried to open the application with some testing apps which allow me to create the intent. But this was not working and also not with my code. My guess for the root of the problem is the generated manifest file from Unity. There are 2 projects exported, the packagename which is visible for adb etc. is within this manifest.

<?xml version="1.0" encoding="utf-8"?>
<!-- GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.app" xmlns:tools="http://schemas.android.com/tools" android:installLocation="preferExternal">
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  <application android:label="@string/app_name" android:icon="@mipmap/app_icon" />
</manifest>

This manifest has no intent-filter and since there is no activity within this project, I’m not sure how I could add one. I think I need an intent filter to make the intent call from outside of my app work. Has anyone solved this before or has an idea how to solve it?

The other manifest looks like this, but has a generic package name which is also not visible from the outside (adb). But this one has an intent-filter. But I’m pretty sure, that I can’t access this with an intent.

<?xml version="1.0" encoding="utf-8"?>
<!-- GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" xmlns:tools="http://schemas.android.com/tools">
  <application>
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:theme="@style/UnityThemeSelector" android:screenOrientation="fullSensor" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="false">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
      <meta-data android:name="android.notch_support" android:value="true" />
    </activity>
    <meta-data android:name="unity.splash-mode" android:value="0" />
    <meta-data android:name="unity.splash-enable" android:value="True" />
    <meta-data android:name="notch.config" android:value="portrait|landscape" />
    <meta-data android:name="unity.build-id" android:value="f5abdf68-b589-4d67-acb2-5c55e15b3fd3" />
  </application>
  <uses-feature android:glEsVersion="0x00030000" />
  <uses-feature android:name="android.hardware.vulkan.version" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />
  <uses-feature android:name="android.hardware.touchscreen.multitouch.distinct" android:required="false" />
</manifest>
How to&Answers:

If this is the android manifest in the temp->staging area folder and you modify it.. it wont work. because unity creates a new android manifest everytime you build it. Instead create an android manifest file in Plugins->Android folder and create the intent-filter and unity will automatically merge the 2 android manifest.

And make sure you make your modifications to the second intent filter the one with VIEW data. add something like android:scheme(im on mobile and just google it and you will find it) and your intent etc.