Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications
by James Talbot, Justin McLean, Jorge Hernandez
Sharing Text and Photos
Next, you need to hook up the share icon so that it knows the context it is in and can share different content based on the activity currently being viewed. You can achieve this by using an object-oriented feature called polymorphism.
In the BaseActivity class, you can create a method named shareActivity that is called when the share icon is touched, but the method does nothing. In each of the activities, you can then override this method and have it share what is currently being displayed. For instance, in the timer screen users might want to share the current time, and in the photo activity they will want to share a photo they’ve just taken. Depending on which activity users are currently in, the right information will ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access