I used Application.Quit, but is not working
public static void Quit()
{
#if UNITY_ANDROID && ! UNITY_EDITOR
Debug.LogWarning("Application Quit");
Application.Quit();
#elif UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#endif
}
This code called from Android device. However, only the game screen freezes when this code is called. and The sound continues to play.
The most suspicious part is the Android Manifest.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.speech.android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:label="@string/app_name"
android:usesCleartextTraffic="true">
<activity android:name="com.company.speech.android.MainActivity" android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This package is for speech recognition AI.
When I tested after deleting this AndroidManifest, Application.Quit() method is Working! i used only one this AndroidManifest.
So I also tried to force the Android process to terminate. However, this method does not fire the OnApplicationQuit event.
Of course, if i use this method, i can also create and use an event called on exit. but, this method has the hassle of registering an event whenever you want to use it.
I'm not good at using Java, it is difficult to use manifest. In addition, this package is also outsourced. So it can't be modified directly.
I would be grateful if there is any code missing from this AndroidManifest or any other good way to exit the app.