09-10-2024 04:42 AM
I'm trying to use a multicast dns library (zeroconf protocol) to register the quest 3 device in the local network.
I've tried the following methods in Unity:
Importing this library: https://github.com/jdomnitz/net-mdns; seems to work on the editor when hitting the play button, but not when building the app on the quest 3.
So I thought maybe it was that the library not being compatible with Android, so I implemented this other library as a java plugin: https://github.com/jmdns/jmdns.
This plugin seems to execute correctly looking the logcat, but it wont publish the service even though I don't get any errors, using this code:
public void startService(String serviceType, String serviceName, int port, String serviceDescription) {
try {
InetAddress address = InetAddress.getLocalHost();
jmDNS = JmDNS.create(address);
ServiceInfo serviceInfo = ServiceInfo.create(serviceType, serviceName, port, serviceDescription);
jmDNS.registerService(serviceInfo);
// This line logs with the correct information but the service doesn't show up
Log.d("JmDNSPlugin", "Service Started: " + serviceName + " with type: " + serviceType + "; port: " + port + "; description: " + serviceDescription);
} catch (IOException e) {
Log.e("JmDNSPlugin", "Error starting service: " + e.getMessage());
e.printStackTrace();
}
}
I'm not sure if it is a permission thing. I have the following manifest code:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:installLocation="auto">
<application android:label="@string/app_name" android:icon="@mipmap/app_icon" android:allowBackup="false">
<activity android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" android:configChanges="locale|fontScale|keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode" android:launchMode="singleTask" android:name="com.unity3d.player.UnityPlayerActivity" android:excludeFromRecents="true" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="com.oculus.intent.category.VR" />
</intent-filter>
<meta-data android:name="com.oculus.vr.focusaware" android:value="true" />
</activity>
<meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="false" />
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only" />
<meta-data android:name="com.oculus.handtracking.frequency" android:value="HIGH" />
<meta-data android:name="com.oculus.handtracking.version" android:value="V2.0" />
<meta-data android:name="com.oculus.ossplash.background" android:value="black" />
<meta-data android:name="com.oculus.supportedDevices" android:value="eureka" />
</application>
<uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
<uses-feature android:name="oculus.software.handtracking" android:required="false" />
<uses-permission android:name="com.oculus.permission.HAND_TRACKING" />
<uses-permission android:name="com.oculus.permission.USE_ANCHOR_API" />
<uses-permission android:name="com.oculus.permission.IMPORT_EXPORT_IOT_MAP_DATA" />
<uses-feature android:name="com.oculus.feature.PASSTHROUGH" android:required="false" />
<uses-permission android:name="com.oculus.permission.USE_SCENE" />
<uses-feature android:name="android.hardware.wifi" android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-feature android:name="com.oculus.feature.CONTEXTUAL_BOUNDARYLESS_APP" android:required="true" />
</manifest>
Solved! Go to Solution.
09-11-2024 04:18 AM
Solved, apparently the library I was trying to use didn't work, I've noticed that Android has built in functions that handles what I wanted to do, and it finnaly worked as expected, using this:
import android.net.nsd.NsdManager;
import android.net.nsd.NsdServiceInfo;
09-11-2024 04:18 AM
Solved, apparently the library I was trying to use didn't work, I've noticed that Android has built in functions that handles what I wanted to do, and it finnaly worked as expected, using this:
import android.net.nsd.NsdManager;
import android.net.nsd.NsdServiceInfo;