微信支付问题:WeChatNotifyActivity} did not call finish() prior to onResume() completing

来源:互联网 发布:淘宝金冠店多少 编辑:程序博客网 时间:2024/05/18 08:04

   在前人留的工程项目中进行渠道替换对接支付,使用的微信支付,但是以前一直都是通过现在支付把微信支付进行了融合,而且只有微信支付,(现在支付是一个集成了支付宝,微信,百度金融,京东金融等平台的聚合类sdk)不知道当初为什么这样设计,只有微信的还有选聚合的sdk。

在Eclpise转Android Studio运行的项目中进行微信支付操作正常,但是当 我把项目中代码全部放到 Android Studio 形式的 工程时再运行出现 调用相应的Activity崩溃。

           

     Android Studio项目                      Eclipse 转 Android Studio项目                                                                                         


崩溃如下:  Caused by: java.lang.IllegalStateException: Activity {com.orange.org_player_new_alone194818.game4399/com.ipaynow.wechatpay.plugin.inner_plugin.wechat_plugin.activity.WeChatNotifyActivity} did not call finish() prior to onResume() completing


在华为4.4的系统上没有出现这个问题,就可能和系统有关。

关键之处就是 did not call finish() prior to onResume() completing

在网上搜到一个 An activity without a UI must call finish() before onResume() completes ,而我们的问题也是和这个类似的。在Android 源码中

final void performResume() {    performRestart();    mFragments.execPendingActions();    mLastNonConfigurationInstances = null;    mCalled = false;    // mResumed is set by the instrumentation    mInstrumentation.callActivityOnResume(this);    if (!mCalled) {       throw new SuperNotCalledException(           "Activity " + mComponent.toShortString() +           " did not call through to super.onResume()");    }    // invisible activities must be finished before onResume() completes    if (!mVisibleFromClient && !mFinished) {        Log.w(TAG, "An activity without a UI must call finish() before onResume() completes");        if (getApplicationInfo().targetSdkVersion                > android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {            throw new IllegalStateException(                   "Activity " + mComponent.toShortString() +                   " did not call finish() prior to onResume() completing");       }   }   // Now really resume, and install the current status bar and menu.   mCalled = false;   mFragments.dispatchResume();   mFragments.execPendingActions();   onPostResume();   if (!mCalled) {       throw new SuperNotCalledException(           "Activity " + mComponent.toShortString() +           " did not call through to super.onPostResume()");    }}


主要部分:

 // invisible activities must be finished before onResume() completes    if (!mVisibleFromClient && !mFinished) {        Log.w(TAG, "An activity without a UI must call finish() before onResume() completes");        if (getApplicationInfo().targetSdkVersion                > android.os.Build.VERSION_CODES.LOLLIPOP_MR1) {            throw new IllegalStateException(                   "Activity " + mComponent.toShortString() +                   " did not call finish() prior to onResume() completing");       }   }

这部分源码就是抛出的崩溃日志
An activity without a UI must call finish() before onResume() completes
也就是我们的Activity 没有UI,所以 要进行主题设置。

<activity android:name=".DialogActivity"     ...    android:theme="@android:style/Theme.Translucent.NoTitleBar"/>


把主题设置为 如上即可。
但是从Eclipse 转的项目 Android Studio ManiFest 都一样,为什么会出现以前项目android:theme 不是Translucent.NoTitleBar可以正常运行,自己创建的 Android Studio会崩溃,然后想了一下应该是 gradle targetSdkVersion 配置问题,targetSdkVersion已经超过6.0了,以前的没有这么高所以运行的时候并不优先选择 6.0系统,而是选择 targetSdkVersion 运行的环境。


所以修复这个问题可以通过修改相应的 activity theme,也可以通过修改targetSdkVersion 修复这个问题


 
阅读全文
0 0
原创粉丝点击