CS 491 Lecture 5a – Intents
Before class
A
Before next class:
- Watch http://youtu.be/2ip2LA3hoR8.
- Read the Intent resolution section of http://developer.android.com/guide/components/intents-filters.html.
Making your own web browser:
- Widgets: WebView, EditText, Button
- LinearLayouts and weight again
- Callback for button clicks
- INTERNET permission
- Handling URL views with an intent-filter* (research better ways)
- Getting intent data back out in onCreate()
B
Before next class:
- Watch http://youtu.be/-r6-mhFVVDc,
- Read http://developer.android.com/guide/components/intents-filters.html until Intent Resolution.
Making a budgeter:
- A main activity with a button
- Implicit intents for the web and phone
- A second activity to get category name and projected amount
- Using an Intent to spawn an Activity
- Using an Intent to spawn an Activity for a result
- Communicating data back to caller via an Intent
In class
You’re pushing out a new social media site called In3. It lets members tell stories with three photos, kind of like a three-panel comic strip. Your task is to create an app that allows the user to create a three panel story with the device’s camera. Consider the following as your develop your app:
- The camera can be conjured with the action MediaStore.ACTION_IMAGE_CAPTURE. In the words of the entire Internet, the Android emulator camera is “flaky.” See your instructor to test on a real device.
- Does the camera require anything in the manifest?
- For a layout, put three ImageButtons side-by-side. When the user clicks on one, take that button’s picture.
- Before the pictures are taken, you can use @android:drawable/ic_menu_camera as the ImageButton’s source attribute.
- The camera activity returns the path where the photo was stored as its intent’s data. You can load it into a bitmap with:
InputStream stream = getContentResolver().openInputStream(data.getData()); Bitmap bitmap = BitmapFactory.decodeStream(stream); stream.close();
- The bitmap will be very big. Shrink it down so all three ImageButtons continue to fit on the screen.
- You can hook up your company’s website to your native app through an intent-filter and a special URL. Have your app respond to intents to view this address: http://www.in3.com/take. (URLs are broken up into scheme://host/path when matching the data of an intent-filter.) When the user visits that link in a browser, it should pop up your app instead. Neat.