来自2个不同通知的公开活动

时间:2017-08-15 05:46:25

标签: android notifications

我在聊天应用中构建通知,然后我从 userA userB 收到 2通知。当我从userA点击notif时,它在我和userA之间打开ConversationActivity。但是当我和userA之间的对话仍然打开时,我点击来自用户B的通知,然后我得到的仍然是我和用户A之间的对话,而不是用户B。这是我构建notif的时候

private NotificationCompat.Builder createTypeNotif(String message, GetCntcResp contact){
        NotificationCompat.Builder builder = new NotificationCompat.Builder(Serv.this);
        String[] parts = splitMessage(message);
        if (parts.length > 1){
            if (parts[0].equals(Serv.CHAT_PROTOCOL) || parts[0].equals(Serv.LOC_PROTOCOL)){
                resultIntent = new Intent(Serv.this, ClassChat.class);
                resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                resultIntent.putExtra(ClassChat.class.getSimpleName() + ".empId", contact.getEmpId());
                resultIntent.putExtra(ClassChat.class.getSimpleName() + ".message", message);
                builder.setSmallIcon(R.drawable.ic_notif_chat)
                        .setContentTitle("Incoming Message")
                        .setContentText("You got message from " + contact.getName());
                builder.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher));
                return builder;
            }else{
                return builder;
            }
        }else{
            return builder;
        }
    }

1 个答案:

答案 0 :(得分:0)

使用此标志开始您的活动而不是单个顶部。 describe('problem view', function() { var view1; beforeEach(function () { view1 = learnjs.problemView('1'); //this is where I am registering the click event callback. I had to call this. I wasn't doing so earlier }); describe ('answer section',function() { it('can check correct answer by hitting a button', function(){ console.log("in It - view1:"+view1.html()) var v1 = view1.find('.answer').val('true'); console.log('clicking'); var b1 = view1.find('.check-btn'); var b2=$("#b") console.log("events: b:"+b2.html()+","+$._data($("#b"),"events")); //b1.click(learnjs.problemView.checkAnswerClick); b1.click(); console.log('v1 is '+v1.val()); console.log('b1 is '+b1.html()); console.log("2nd events: "+$._data($("#b"),'events')); var r =view1.find('.result'); console.log('r is '+r.text()); //spyOn(learnjs,'learnjs.problemView.checkAnswerClick'); expect(view1.find('.result').text()).toEqual('Correct!'); //expect(learnjs.problemView.checkAnswerClick).toHaveBeenCalled(); }); 了解详情here