bug: 微信分享后返回app时偶现出现黑屏问题
<activity
android:name=".wxapi.WXEntryActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true"
android:theme="@style/TranslucentTheme"
android:taskAffinity="com.zhugefang.agent"
android:launchMode="singleTask"/>
public class WXEntryActivity extends AppCompatActivity implements IWXAPIEventHandler {
private IWXAPI api;
private SocialHelper socialHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
socialHelper = new SocialHelper.Builder().build();
String wxAppId = socialHelper.getBuilder().getWxAppId();
api = WXAPIFactory.createWXAPI(this, wxAppId, true);
api.registerApp(wxAppId);
try {
api.handleIntent(getIntent(), this);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
api.handleIntent(intent, this);
}
@Override
public void onReq(BaseReq baseReq) {
}
@Override
public void onResp(BaseResp baseResp) {
//登录
Log.d("WXEntryActivity", baseResp.errCode + baseResp.errStr);
if (baseResp.getType() == ConstantsAPI.COMMAND_SENDAUTH) {
if (baseResp.errCode == BaseResp.ErrCode.ERR_OK) {
String code = ((SendAuth.Resp) baseResp).code;
// SocialUtil.getInstance().socialHelper().sendAuthBackBroadcast(this, code);
socialHelper.sendAuthBackBroadcast(this, code);
} else {
// SocialUtil.getInstance().socialHelper().sendAuthBackBroadcast(this, null);
socialHelper.sendAuthBackBroadcast(this, null);
}
} else if (baseResp.getType() == ConstantsAPI.COMMAND_SENDMESSAGE_TO_WX) {
if (baseResp.errCode == BaseResp.ErrCode.ERR_OK) {
// SocialUtil.getInstance().socialHelper().sendShareBackBroadcast(this, true);
socialHelper.sendShareBackBroadcast(this, true);
} else {
// SocialUtil.getInstance().socialHelper().sendShareBackBroadcast(this, false);
socialHelper.sendShareBackBroadcast(this, false);
}
}
onBackPressed();
}
}