teaching machines

Homework2-kruegeba

October 19, 2011 by . Filed under cs491 mobile, fall 2011, postmortems.

I made a simple note taking app the shadows the Rattler interface (due to time crunch).

           

Basically you are able to create simple notes to yourself that include a basic subject title as well as the body text.  The user is able to delete any note from the main screen by pressing on the red X button, and they can also hear the body text of a note spoken to them by pressing the blue play button.  The date is automatically placed with any note so the user does not have to deal with that.  When the save button is pressed, it automatically sends the user back to the main activity screen.  One thing I spent a lot of time on, was trying to figure out how to communicate between non-activity classes and activity classes.  An example of this was trying to figure how to make the buttons delete the note item since it is done in the Note Adapter class which is not an activity.  Same with the play button which is also set off in the Note Adapter class (since the text to speech needs a context to play). The best solution I could figure out was to create some public methods in the main activity (speakText and delete) and then pass the main activity into the constructor of the Note Adapter:

public NoteAdapter(Context context, QuickNoteActivity main)

Unfortunately I started late and ran out of time to do something creative, but I wanted to implement another button on the main screen that would send that note to an email address.  A lot of internet posts on sending emails from an android app stated that it could not be done in the emulator, so I would possibly have to get a device to test that.  Some code I found related to this was:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT   , "body of email");
try {
    startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}