Displaying a Chooser

For users to select the app they want to use for sharing, you need to create or launch a chooser control that Android displays in the user interface. Here’s how.

1. Create a new class named Share in the com.androiddevbook.onyourbike.chapter8.helpers package. Create a static string named CLASS_NAME to store the class’s name, and create a constructor in the usual way. Create a property of type Activity, and set this from the activity parameter passed into the constructor (see Listing 8.28).

Listing 8.28 Building the Framework for the Share Class

public class Share {    private static String CLASS_NAME;    private final Activity activity;    public Share(Activity activity) {        CLASS_NAME

Get Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.