Showing posts with label Intents. Show all posts
Showing posts with label Intents. Show all posts

Wednesday, April 6, 2011

Nice and Smooth - Sending email

After having a horrible time with permissions last night, I moved on to figuring out how to send an email with an attachment. It turns out that this is the easiest thing that I've done on Android so far! I just had to create an Intent to ACTION_SEND, add some parameters that are pretty standard, and start her up.

Here's the code:
     Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ "youremail@gmail.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Checkins today");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Here you go.");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/barcodes/checkins.txt"));
emailIntent.setType("text/csv");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
It's looking more and more like this thing will be ready for prime-time before the B5s race next week. Todd might be pleasantly surprised if he gets the check-ins before the race starts.

Sunday, April 3, 2011

Progress: Barcode check-in app

I made some progress on my barcode scanner app for GVCC last night. After screwing around for 2 hours trying to compile zxing in Eclipse, I gave up and used the "cheap" way and just used the barcode scanner through Intents. What a difference! Used/modified the example code snippet that zxing posted on their website, and within 10 minutes I was scanning barcodes and displaying the results on the screen.

Now I just have to finish up by writing those scanned codes into a file and allowing the user to email the file to a configured email address once all of the scans are completed. I tried messing with the file system, but I don't think I have the permissions set right, or maybe I'm just not saving the file to the correct location. Shouldn't be too hard to figure out, but I just need to get in there and figure out why it's not working.