Is there any way to know the game is running in an emulator application or a real device ?
Some Applications like VirtualXposed are virtual emulator for android devices. Such Applications allow users to install a game / application multiple times on their device with different identifies.
I want to know is there any way to recognize my game / application is running in emulator or a physical device in unity3d ?
something like :
if(isemulator)
{
dosomething();
}
It's not easy to do since there are many emulators out there. The answer from this post says that you can use Build.FINGERPRINT.contains("generic") to do that.
You can port the Java code to C# in Unity with the AndroidJavaClass class and without building Java plugin. Below is the ported version in C#:
public bool IsEmulator()
{
AndroidJavaClass osBuild;
osBuild = new AndroidJavaClass("android.os.Build");
string fingerPrint = osBuild.GetStatic<string>("FINGERPRINT");
return fingerPrint.Contains("generic");
}
To make sure that this covers most emulator, use the android-emulator-detector plugin. This plugin seems to be rigorously tested and detects most emulators. You can use AndroidJavaClass to communicate with it and UnityPlayer.UnitySendMessage to make callback into your Unity code in C#.
Maybe you can look for some emulator specific SystemInfos (Unity Docs SystemInfo) eg. SystemInfo.deviceModel
Related
I'm trying to send GPS-coordinates from an Android device to the Hololens by BLE-advertisments.
The problem as far as i see, the events from BluetoothLEAdvertisementWatcher do not trigger on the Hololens.
I have tried copy-paste both this implementation
and this on the receiver side, no received event.
This is the current implementation in Unity, i have implementated the same functions in a blank UWP-C# project and deployed directly on the Hololens with the same result.
private void StartWatcher()
{
void OnAdvertisementReceived(object sender, BluetoothLEAdvertisementReceivedEventArgs eventArgs)
{
Debug.Log("Event triggered"); // switched to Write-line on the C#->UWP implementation
}
void OnAdvertisementStop(object sender, BluetoothLEAdvertisementWatcherStoppedEventArgs eventArgs)
{
Debug.Log("Event triggered"); // switched to Write-line on the C#->UWP implementation
}
try {
BluetoothLEAdvertisementWatcher watcher = new BluetoothLEAdvertisementWatcher();
watcher.AdvertisementFilter.Advertisement.ManufacturerData.Add(GetManufacturerData());
watcher.Received += OnAdvertisementReceived;
watcher.Stopped += OnAdvertisementStop;
watcher.Start();
Debeug.Log("Started"); // switched to Write-line on the C#->UWP implementation
} catch (Exception e){
}
}
private BluetoothLEManufacturerData GetManufacturerData()
{
var manufacturerData = new BluetoothLEManufacturerData();
manufacturerData.CompanyId = 0X06EF;
return manufacturerData;
I know the advertisements are sent, becuase if i debug the native UWP-application directly in Visual Studio on the PC(even as ARM64), everything works. The events are triggered.
The watcher.Status reports "started" on the Hololens
Even if i disable the Bluetooth on the HoloLens while the application are running, the stop-event are not either triggered.
If i check watcher.Status after i disable the Bluetooth, the status reports aborted but the Stoped-event are not recieved.
The capability is activated following this article
Now to where it gets wierd.
During one of my first tries i had my application running on the Hololens as i've tried to remove the pairing between the Android device and HoloLens.
The android devices appears as two devices on the Hololens, device name as one and "LE"+MAC as the other.
Sometime during the time i was in the Bluetooth settings and removed the two adapters from the cellphone, the HoloLens recieved three separate advertisments. The data in the advertisments was also confirmed from my Android device becuase during my inital tries i parsed the data.
But thats it, i have tried to replicate this for 10 hours today, Pair and unpair the different adapters in different stages while listening for recieve events but without luck.
On my PC, it do not matter if the adapters are paired or not.
I have tried both .NET Standard 2.0 and .Net 4.x as API Compatibility Level.
I have set breakpoints in both the receive and Stoped event-handler as i was afraid that the calls from the Event-functions was the problem. As far as i see, we never reach the implemented events.
Any suggestion on what might be the next step to check is appreciated.
The Hololens Build is 19041.1144.
Ok, so i can now recevie advertisments on the HoloLens by running the example provedied by Microsoft.
I could not receive any events at all and no updates was available in the settings, so i've reinstalled all applications in the Microsoft Store and that seems to be the solution for me. After that and a restart of the HoloLens i was able to recieve advertisements from my PC.
Another tip for other tip for people trying to recieve advertisements on the HoloLens 2.
When i was able to receive advertismements from my pc i saw that the advertisments from my Android device was not recieved on the HoloLens, but recieved on the PC.
The advertisments on my PC was of type NonConnectableUndirected and from my Android device ScannableUndirected.
I needed to change to "AdvertisingSet" and in the AdvertisingSetParameters set both isConnectable and isScannable to false to be able to send NonConnectableUndirected.
Now the HoloLens recevies the advertisments from my Android device.
My xamarin.forms app is meant to join a Zoom meeting on a mobile device using Launcher.OpenAsync() with a uri scheme of the form "zoomus://zoom.us/join?confno=1234567890&pwd=123456".
This works fine on Android, but on iOS it doesn't seem to do anything at all. I call Launcher.CanOpenAsync() beforehand, and that returns true, so the uri should be OK. The Zoom app is already installed. In info.plist I have added zoomus (and zoom) to LSApplicationQueriesSchemes.
My code looks like this:
private void RunZoomAsync()
{
Task zoomTask = Task.Run(async () =>
{
if (await Launcher.CanOpenAsync(selectedMedia.Uri))
{
Message = "Launching Zoom";
await Launcher.OpenAsync(selectedMedia.Uri).ConfigureAwait(false);
}
else
{
Message = "Zoom not found. You must install Zoom from your App Store";
}
});
}
I see the message on the screen, so I know it's getting to the right bit of code.
I tried sending the same link to the iPhone in an email and that does nothing either. (I tried that on the Android phone, and the email app wouldn’t even display the link as a hyperlink). Is there some setting on the iPhone, or in my app, to allow deep linking?
As you may have guessed, I am not normally an iPhone user. I’m using an old iPhone 6 for testing, running iOS 12.4.8.
I have sought help from the Zoom developer forum, who suggested that when using url schemes in iOS, there is an AppDelegate function that needs to be overridden:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool
I'm guessing the above is not C#, and that the Essentials Launcher class deals with whatever is required in iOS.
Am I missing something, or is this a bug? Any help gratefully appreciated.
I tried sending the same link to the iPhone in an email and that does
nothing either. (I tried that on the Android phone, and the email app
wouldn’t even display the link as a hyperlink). Is there some setting
on the iPhone, or in my app, to allow deep linking?
This needs to work if you have installed the app and if you are using the proper protocol and if your hardware and operating system is working properly. Your problem is not caused by your code (well unless you are using the wrong protocol), so this is the answer for this site as it doesn't deal with non-coding problems.
Why your Zoom app is not working as expected - you should start with the Zoom customer support as they are in the best position to give you the answer if it exists, but it is extremely likely that your device is faulty in some way.
My problem was that I wasn't running the Launcher in the main thread, so (I assume) the Zoom app didn't have access to the screen. So I just changed:
Task zoomTask = Task.Run(async () =>
to:
MainThread.BeginInvokeOnMainThread(async () =>
and it's now working!
I'm trying to create a simple application in UWP for a Zebra device (Model TC700J) running Windows 8, in which I make use of the built in barcode scanner.
From what I've found, there's plenty of Zebra tutorials for accessing the scanner when programming on Android, but none for Windows due to the fact that Microsoft provide their own generic barcode scanner API found in the Windows.Devices.PointOfService namespace.
The code I currently have looks something like this:
BarcodeScanner scanner;
ClaimedBarcodeScanner claimedScanner;
scanner = await BarcodeScanner.GetDefaultAsync();
if (scanner != null)
{
claimedScanner = await scanner.ClaimScannerAsync();
}
The problem is that the if statement never evaluates to true as the GetDefaultAsync method always returns null.
Over here there was an answer that seemed to work, stating that it depends where the GetDefaultAsync method is placed. I've tried to put it in all of the suggested places though and to no avail.
There is another method, BarcodeScanner.FromIdAsync() which returns a barcode based on the string representation of that barcode scanner's id sent as a parameter, but I'm not sure that'd be valid here as the barcode scanner is built into the device.
Looking at Zebra's site, TC700J seems to be model number of Windows 10 Mobile IoT Enterprize OS.
And the platform is ARM(Qualcomm snapdragon), not Intel x86/x64.
TC70 / TC75 Touch Computer Series
https://www.zebra.com/us/en/products/mobile-computers/handheld/tc7x-touch-computer-series.html
TC70x Operating System (TC700J) Windows 10 Mobile IoT Enterprise v1.13.02 Release Notes
https://www.zebra.com/us/en/support-downloads/software/release-notes/operating-system/tc70x-operating-system-v1-13-02--release-notes.html
For example, if your Zebra device is old hardware and Windows Phone 8/8.1 is running, Windows Phone does not seem to support Windows.Devices.PointOfService namespace.
It is described in the comment of the following article.
Windows Phone 8.1: Scan Barcodes using Camera
If your Zebra device can update to Windows 10 Mobile IoT Enterprise, please check it after doing it.
If you can update it, you can use the barcode scanner sample for Windows 10.
https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/BarcodeScanner
If your device is running on Windows 8 for x86, since Windows.Devices.PointOfService namespace is supported from Windows 8.1, you need to change the OS to Windows 8.1/10 if possible.
In that case you can use following, or above(for Windows10) sample.
Barcode scanner sample for Windows 8.1
https://code.msdn.microsoft.com/windowsapps/Barcode-scanner-sample-f39aa411
If you can not update it, please get the software and documentation for using BarcodeScanner from the vendor on Windows (Phone?) 8.
Seems the usage of Async method wasn't quite right.
Try below code:
BarcodeScanner scanner;
ClaimedBarcodeScanner claimedScanner;
scanner = await BarcodeScanner.GetDefaultAsync();
if (scanner != null)
{
claimedScanner = await scanner.ClaimScannerAsync();
}
More details:
https://learn.microsoft.com/en-us/dotnet/csharp/async
https://msdn.microsoft.com/en-us/magazine/jj991977.aspx?f=255&MSPPError=-2147217396
I'm developing a game for Windows Phone 7.1 with XNA framework.
I know there is a way to prevent piracy for Windows Phone 7 (and 8.0, 8.1) - checking if the file "WMAppPRHeader.xml" exists in app directory.
I'm using this code:
try
{
Stream stream = TitleContainer.OpenStream("WPAppPRHeader.xml");
if (stream.CanRead)
{
stream.ReadByte();
stream.Close();
}
}
catch
{
//file read error, it means it was hacked
}
When use this code and upload my game to Windows phone marketplace as a "Beta" app, it works great. File "WPAppPRHeader.xml" is readable from my game and the test is passed.
But, when upload the same XAP in Windows Phone marketplace as a public app, this code fails and my game thinks that it was hacked (I'm checking this somewhere in the middle, so microsoft testers doesn't event recognise that something is wrong and my game succesfuly passes certification).
So, what am I doing wrong? Why the same code, the same XAP is working when it's Beta, and not working when it's Public?
I still don't know why TitleContainer.OpenStream is working in beta and not working in public market, but here is the code, that works in public market:
System.Xml.Linq.XDocument.Load("WPAppPRHeader.xml");
I am developing a C# device application for Motorola MC55 devices (Bluetopia is used). This application sets the bluetooth inquiry and pairing procedure in motion (by means of the Enterprise Mobility Developer Kit) and writes down the virtual serial port #:
public void DoConnection(IRemoteBTDevice rd)
{
RemoteDevice remoteDevice = new RemoteDevice(rd.DeviceName, rd.Id.Replace(":", ""), "");
this.bluetooth.RemoteDevices.Add(remoteDevice);
this.bluetooth.RemoteDevices.Refresh();
if (!remoteDevice.IsPaired)
{
remoteDevice.Pair(rd.Pin);
}
//TODO Note serial port # (get it by means of remoteDevice.LocalComPort)
//Works smoothly, but a second process has to do this (requirement).
remoteDevice.OpenPort();
}
But as soon as a second process (e.g. another c# device application) opens that serial port, BTExplorer is launched. How do I suppress this phenomenon?
this.comX = new SerialPort(this.BluetoothPortName);
this.comX.Open();
I'm just using another Assembly: http://32feet.codeplex.com/. It works smoothly for Motorola ES400 (Microsoft Stack). After seeing this: http://32feet.codeplex.com/wikipage?title=Stonestreet%20One%20Bluetopia, I used the same code, but it doesn't work trouble-free for MC55 yet.
Thank you for your support,
Roger Huber
As I understand it, it is BTExplorer.exe that actually provides/controls the virtual COM port service, so it needs to be running when a virtual COM port is in use...
Do be sure to let know what the issues you see on your MC55 when using my 32feet.NET Bluetopia support. As I noted at 32feet.NET: Stonestreet One Bluetopia I tested on a M3 Mobile device which has a quite recent version of the Bluetopia stack. Maybe StoneStreetOne changed something between your versions... (If Bluetopia start-up fails completely then I've more logging in version 3.3 -- which I'm not too far away from releasing).
Of course if that second C# program needs to use a virtual COM port then 32feet.NET won't help -- BTExplorer is still required as discussed above. However if you could change that program to use BluetoothClient etc instead of COM ports... (Remembering of course the "Bluetopia one at a time" restriction of course).
Alan