How to pass text from notification to another activity?

后端 未结 1 350
隐瞒了意图╮
隐瞒了意图╮ 2021-01-27 06:05

in my application, when i click list view item one notification will display, Now when i click that notification open another activity and display the notification content in an

相关标签:
1条回答
  • 2021-01-27 06:26

    Finally i found answer for this task.First write this line into onNewIntent(getIntent()); Oncreate() method. After add this code to your Activity.

    protected void onNewIntent(Intent intent) {
        // TODO Auto-generated method stub
        Bundle extras = getIntent().getExtras();
        if(extras != null){
            if(extras.containsKey("Name")){             
                setContentView(R.layout.notification);
                // extract the extra-data in the Notification
                ok_btn=(Button)findViewById(R.id.not_ok);
                String msg = extras.getString("Name");
                not_data = (TextView) findViewById(R.id.noti_txt);
                not_data.setText(msg);              
            }
        }       
        super.onNewIntent(intent);
    }   
    

    any doubts in this task plse post ur question.

    0 讨论(0)
提交回复
热议问题