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.
Aryan Kumar
27-Jun-2023To 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.Samuel Fernandes
27-Jun-2016Hi Jones try this below code