fix:android unwarp return activity

This commit is contained in:
刘涛 2021-02-24 11:57:40 +08:00 committed by osborn
parent 04c19992ad
commit 411c92f0f0

View File

@ -15,6 +15,7 @@
*/
package pub.doric.utils;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.AssetManager;
@ -323,10 +324,9 @@ public class DoricUtils {
}
public static Context unwrap(Context context) {
while (context instanceof ContextWrapper) {
while (!(context instanceof Activity) && context instanceof ContextWrapper) {
context = ((ContextWrapper) context).getBaseContext();
}
return context;
}
}