3 回答

TA貢獻(xiàn)1827條經(jīng)驗(yàn) 獲得超9個(gè)贊
在 MainActivity 的 onActivityResult 里面使用這個(gè):
而不是這個(gè): -
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Fragment servicesFrag = bottomNavAdapter.getItem(mainViewPager.getCurrentItem());
if (servicesFrag instanceof ServicesFragment) {
((ServicesFragment) servicesFrag).onActivityResult(requestCode, resultCode, data);
}
}
用這個(gè) :-
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
for(Fragment fragment : getSupportFragmentManager().getFragments()){
fragment.onActivityResult(requestCode,resultCode,data);
}
}
讓我知道它是否有效

TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超9個(gè)贊
請(qǐng)將此行添加到活動(dòng)中的 onActivityResult
Fragment servicesFrag = bottomNavAdapter.getItem(mainViewPager.getCurrentItem());
Fragment addressFrag = findFragmentByTag("NewAddressFragmentTag");
if (servicesFrag instanceof ServicesFragment) {
((ServicesFragment) servicesFrag).onActivityResult(requestCode, resultCode, data);
}
if (addressFrag instanceof NewAddressFragment) {
((NewAddressFragment) addressFrag).onActivityResult(requestCode, resultCode, data);
}
}

TA貢獻(xiàn)1735條經(jīng)驗(yàn) 獲得超5個(gè)贊
我可以解決我的問(wèn)題!
使用以下代碼更改 MainActivity 代碼:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Fragment servicesFrag = bottomNavAdapter.getItem(mainViewPager.getCurrentItem());
Fragment addressFrag = getSupportFragmentManager().findFragmentByTag("NewAddressFragmentTag");
if (servicesFrag instanceof ServicesFragment) {
((ServicesFragment) servicesFrag).onActivityResult(requestCode, resultCode, data);
}
if (addressFrag instanceof NewAddressFragment) {
super.onActivityResult(requestCode, resultCode, data);
}
}
我希望對(duì)另一位親愛(ài)的開(kāi)發(fā)人員有所幫助
添加回答
舉報(bào)