Week 8 - Android Action Bar, Hardware Sensors, Custom Dialogs, Multi-Touch, Photo Gallery, More Drawing Flashcards
In the Holo theme, what happens to action bar items that do not fit on the screen?
They are placed into a drop down menu at the end of the bar. This is theme dependent.
What is the Android Action Bar?
It is a horizontal bar near the app title containing tabs and buttons.
Without a SurfaceView, how can one draw on on a view?
By overriding the view’s onDraw() method and adding code to draw onto the view’s canvas.
What was the strategy used in the Doodlz app to create and render painted strokes?
The strokes are determined from touch events and are used to create paths that are updated. When the user stops drawing a stroke, the associated paths are flushed to a bitmap which is drawn onto the view’s canvas at each frame.
How is a custom dialog created and shown to the user?
By instantiating the Dialog class and calling its setContentView() method on the resource reference to the XML layout file containing the dialog UI, then setting listeners for each view that needs to react to user input.
How does one start listening to a sensor?
Example using the accelerometer
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
sensorManager.registerListener(sensorEventListener,
sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
SensorManager.SENSOR_DELAY_NORMAL);
What was the strategy used in the Doodlz app to handle drawing touch input?
The onTouchEvent() callback was overridden and the type of touch was determined. If it was a touch down event, a new path is created. If it was a touch up event, the current path is ended. If it was a touch move event, the current path is continued.
The pointer ID is extracted from the touch event and used to identify paths.
How is an image saved to the image gallery?
A URI is obtained from the OS that points to the location where image media are stored. An OutputStream is opened on that URI, and the image data is written out.