code: @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          // storing string resources into Array
          String[] pages = getResources().getStringArray(R.array.pages);
  
          // Binding resources Array to ListAdapter
          this.setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, pages));
  
          ListView lv = getListView();
  
          // listening to single list item on click
          lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
                // selected item
                String product = ((TextView) view).getText().toString();
  
                // Launching new Activity on selecting single List Item
                Intent i = new Intent(getApplicationContext(), TestActivity.class);
                i.putExtra("product", product.concat(" page"));
  
                if (product.equals("WebView")) {
                    i = new Intent(getApplicationContext(), WebviewActivity.class);
                } else if (product.equals("Notification")) {
                    // generate a notification instead of starting a new activity
                    NotificationManager notificationManager = (NotificationManager)
                            getSystemService(NOTIFICATION_SERVICE);
  
                    PendingIntent pIntent = PendingIntent.getActivity(getApplicationContext(), 0, i, 0);
  
                    Notification n  = new Notification.Builder(getApplicationContext())
                            .setContentTitle(getString(R.string.notification_title))
                            .setContentText(getString(R.string.notification_text))
                            .setContentIntent(pIntent)
                            .setSmallIcon(android.R.drawable.ic_dialog_alert)
                            .setAutoCancel(true).build();
  
                    notificationManager.notify(0, n);
                    System.out.println("HelloWorld:: Sending notification");
  
                    return;
                }
  
                // sending data to new activity
                startActivity(i);
            }
          });
      }
docs: Called when the activity is first created.