First I use Unity to open an webview(by plugin named "uniwebview"). Then I open camera or gallery(by stan's android native plugin) or browser(By Application.OpenURL(url)). After I select picture and back to unity. If adb log like this:
I/Unity (12779): onPause //open camera and Unity pause
I/Unity (12779): windowFocusChanged: true // after take picture, windowFocusChanged set true and unity resume
I/Unity (12779): onResume
I/Unity (12779): OnAndroidRetrieveProductsFinished
Then Unity work fine, but sometimes if adb log like this:
I/Unity (12779): onPause
I/Unity (12779): onResume
Unity's function will be blocked.The code I had written in Unity will not work but webview still work fine. I decompilation classes.jar in Unity and found the function windowFocusChanged:
public void windowFocusChanged(final boolean paramBoolean)
{
i.Log(4, "windowFocusChanged: " + paramBoolean);
this.i.a(paramBoolean);
if ((paramBoolean) && (this.b != null)) {
reportSoftInputStr(null, 1, false);
}
c(new Runnable()
{
public final void run()
{
UnityPlayer.a(UnityPlayer.this, paramBoolean);
}
});
this.a.a(paramBoolean);
g();
}
But I don't know why this function is not work. classes.jar has been obfuscated and hard to read.
I don't know how it works with that plugin we're using "Native Gallery Assist" - https://www.assetstore.unity3d.com/en/#!/content/60922 which reutrns fine back into unity with the image selecgted...
Unity lost focus when you open other app or interact with other application. If you want to run your functions in background after unity app loses focus then follow the steps below:
Now your functions will run even after unity loses focus.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With