Android:BroadcastReceiver清除活动实例堆栈

时间:2013-10-10 01:04:09

标签: android android-activity broadcastreceiver

我在我的主要Android活动中有一个BroadcastReciever,它可以从活动堆栈上点击一下的另一个活动调用。当调用BroadcastReciever时,活动堆栈被清除,后退按钮将我带回BroacastReciever的主活动。当它没有被调用时,后退按钮按预期工作,将我带到活动堆栈。

如何在调用BroadcastReciever时阻止活动堆栈被清除?

这发送广播:

final Intent connIntent = new Intent("REFRESHFEED");
connIntent.putExtra("feedRefresh", feedRefresh);
connIntent.putExtra("itemsAdded", numItemsAdded);
context.sendBroadcast(connIntent);

在主要活动中,这是BroadcastReceiver:

private final BroadcastReceiver updatefeed = new BroadcastReceiver() {
    @Override
    public void onReceive(final Context context, final Intent intent) {
        Boolean feedRefresh = intent.getBooleanExtra("feedRefresh", true);
        int numAdded = intent.getIntExtra("itemsAdded", 0);
        int numFollowed = prefs.getInt(PreferenceHelper.NUMPLAYLISTS, 0);
        if(headerSubTitle!=null) {
            if(numFollowed>0) {
                headerSubTitle.setVisibility(View.VISIBLE);
                headerSubTitle.setText("FOLLOWING "+ numFollowed + (numFollowed==1?" SEARCH":" SEARCHES"));
            } else headerSubTitle.setVisibility(View.GONE);
        }

        if(feedRefresh) {
            setPagerAdapter(false);
            loadFeed(false, true, false, false);
        } else {
            if(feedAdapter!=null && numAdded>0) {
                int numPrev = Integer.valueOf(notifyNewFeedText.getText().toString().split(" ")[0]);
                numAdded = numAdded + numPrev;
                if (numAdded==1) {
                    notifyNewFeedText.setText(numAdded + " New Items");
                } else {
                    notifyNewFeedText.setText(numAdded + " New Items");
                }
                notifyNewFeed.setVisibility(View.VISIBLE);
                refreshFeedItem.setIcon(R.drawable.refresh_new);
            }
        }

    };
};

0 个答案:

没有答案