Android ContextThemeWrapper cannot be cast to android.app.Activity

java.lang.ClassCastException: android.view.ContextThemeWrapper cannot be cast to android.app.Activity

Dialog中的context,在强制装换Activity出现。

将(Activity) mContext,变成:scanForActivity(mContext)

private static Activity scanForActivity(Context cont) {
    if (cont == null)
        return null;
    else if (cont instanceof Activity)
        return (Activity)cont;
    else if (cont instanceof ContextWrapper)
        return scanForActivity(((ContextWrapper)cont).getBaseContext());

    return null;
}


你可能感兴趣的:(android,代码,native,Studio,YaphetZhao,Yaphet赵勇)