ANDROID - How to force ANR with Unity - c#

I'm making a game with Unity for Android. I want to generate a ANR for testing purposes, and when I say ANR I mean that Android displays that window indicating the app is not responding, I want that window appearing.
I tried using a Thread.Sleep(); and a while (true) { }, but had no effect. The game freezes and is unresponsive, but the Android window saying "App not responding" is not appearing.
Also, I want to generate it with C#. I know using Java files to generate an ANR directly on the Android UI thread works, but I want to provoke it just using Unity code.
Hope someone can help!

Related

Is there a way to turn on/off microphone "listen to this device" with code?

I want to quickly toggle "listen to this device" on a certain microphone input without having to alt-tab to a diffrient window to do it.
I've tried looking at documentaion for .net, but im not sure if i can find what I need there.
Edit: Im new to this kind of stuff, and im not sure if my terminology is right, or if im even using the right things.
Edit2: My operating system is Windows 11 Build 22621 and im trying to write a program in Visual Studio Code, C# and Im using .net as the base. Im just trying to make a program, that when ran, checks the current state of the "Listen to This Device" and flip it.

Game restarts after lose focus Unity iOS

I have such problem:
After lose focus, my application restarts, I'm trying to play with custom behaviours, but it isn't work.
Platform: iOS
Unity: 2020.3.26f1
I had the exact same problem but in Android. I searched for hours and tried many different things.
The problem was that I had a piece of code well hidden invoking Unity method OnApplicationPause(). That method was the one responsible for closing the window. Double check if that's not ur case or something like it!

Keep Unity program working in background after device goes to sleep?

I'm working on a Unity project that uses the device camera for AR purposes (I'm using AR Foundation). I currently have it set so that the device won't go to sleep (because I want it to operate for long-periods without user-interaction). Specifically, Screen.sleepTImeout = SleepTimeout.NeverSleep. If I didn't have this, then the device would go to sleep, and the program would stop functioning. Does anyone know if there is a way to keep the program working in the background after the device goes to sleep...similar to how music apps keep playing music? I've come up empty handed after a few hours of searching for a solution. Any help would be greatly appreciated!!!
Some people aren't finding this in more recent versions of Unity. But it's still there: In Player settings, under the section "Resolution and Presentation", you find "Resolution" and below that, there's "Run In Background".
This is only available for Web players and standalones (Anything Except IOS And Android Pretty Much), though (you won't find it when you have the iOS, Android or Flash tab selected.

Xamarin Cross Platform Splash Screen on App boot

Yo. Some of you might already know but Xamarin Apps are booting pretty slow and the delay occurs before any line of code is executed - at least i figured that out with some breakpoints.
So i want to cover that up using a Splashscreen. But since Xamarin is for multiple platforms i'd like to... welll... use cross platform code.
The most important part is: i do NOT want to cover my code delay. I want to App to NOT open with a white blank screen like it currently does, but e.g. with an image or some animation or such stuff.
and yes i already googled a little but everything i found seemed to be android specific or iphone stuff, or it just takes affect after the system boots.
There is no cross-platform way to do that yet. (Answering in 2017/Dec)
You'll need to make it for each platform.
Android: https://developer.xamarin.com/guides/android/user_interface/splash-screen/
iOS: https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_images/launch-screens/

How do I run Game1 on click of a button in another form

I'm a beginner programmer and I am trying to get a bit into c# and xna. I was hoping that instead of having the game run immediately (as usual), I wanted to have some sort of a register/login process, although I don't know how to run the game1.cs when the login button is clicked. In a few words, I would like some help with how I can run the:
using (Game1 game = new Game1())
{
game.Run();
}
on the login-button click in the login form.
Have you considered creating your login-screen using XNA itself instead of employing forms? This way you will be able to deploy your XNA game more easily on different platforms such as the XBox360 and Windows Phone.
A gamestate manager and a keyboard-handler class should help you get well underway and allow much more flexibility for background music, sound and video while logging in.
If you really want to though, there's this article that might help you out.

Categories