In the openActivity() method, you can add the code to start the activity that you want to open when the user clicks on the button.
Code snippet
public void openActivity(View view) {
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
}
Save the XML file and compile your project.
When you create a notification, you can use the setCustomContentView() method to set the content view of the notification to the XML layout that you created. This will display the notification with the text and button that you defined in the XML layout.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
To create an XML layout for a notification activity, you can use the following steps:
notification_layout.xml.Code snippet
openActivity()method, you can add the code to start the activity that you want to open when the user clicks on the button.Code snippet
When you create a notification, you can use the
setCustomContentView()method to set the content view of the notification to the XML layout that you created. This will display the notification with the text and button that you defined in the XML layout.Hi Jones try this below code