Wednesday, August 24, 2011

Android action_send multiple images

Android OS makes it really easy to share an image programmatically, using the ACTION_SEND intent. I had a situation recently, while porting my iBridalGown for iOS app to Android, where I wanted to send an email with multiple image attachments. As with most Android programming tasks, there were first a few snafus to overcome ;) A couple of the problems I was facing were:
  1. ACTION_SEND actually can only handle one image attachment.
  2. The images were saved in the "private" app directory (the one you get when you call getFilesDir()) , which is problematic when attaching images to emails this way.
  3. There are not many clients that respond to ACTION_SEND which can accommodate text/html content and an attachment, let alone multiple attachments
So, what did I do? Three problems, three solutions:
  1. I used the ACTION_SEND_MULTIPLE intent, in order to send multiple attachments.
  2. I made temporary copies of the images in external storage before attaching them to the intent.
  3. I made sure only Gmail would be launched, since it is the only app I found which can reliably handle sending text/html and multiple image attachments.
More details...

Monday, August 22, 2011

Android programmatic density independent pixels

I've been doing a bunch of Android programming lately, working on porting the iBridalGown iOS app to Android, so I've been using a lot of "dip" (density independent pixels) measuring in my layouts. For example, in a TextView, I might specify something like this in XML:

<TextView
      android:id="@+id/headertext"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:minHeight="48dip"
      android:textSize="24dip"
      android:text="My Dresses"
/>

But what if, within the Activity code, I want to change one of these measurements? There are no Java methods in the Android SDK that accept density independent pixels!

Well, here's how. Just multiply the size in pixels by a scale factor defined in the context's resources, like so:

float scale = context.getResources().getDisplayMetrics().density;
float size = sizeInPixels * scale;

And there's that. I hope it helps :) Please join the conversation with a comment.

Wednesday, July 13, 2011

7 Funny Unattended Children Signs

Here are a few funny reminders to keep track of your kids :)

The Classic.

This time a double espresso and imaginary perks.

Friday, July 8, 2011

SEO Tip - Custom Blogger Post URL

It's very important for SEO (search engine optimization) to have a meaningful blog post URL in your Blogger or Blogspot blog. Blogger will create a post URL automagically using the post title. So, if my post was titled "My post about iPhone programming", I would see a URL like http://blog.daveworld.net/2011/07/my-post-about-iphone-programming.html.

But sometimes this plan gets thwarted by the length of the title. In fact, if your title is over 40 characters, there's a good chance the URL will be truncated to something that is NOT satisfactorily search engine friendly.

For example, my last blog entry was titled "How To Follow More Than 2000 People on Twitter". You can see it here.

How To Follow More Than 2000 People on Twitter

If you are using Twitter and are trying to follow more than 2,000 people, you may encounter the following message:
"Your account may not be allowed to perform this action. Try logging out and in again."

Do not despair. What you need to do is get more followers. When you reach around 1850 followers, then you will be able to follow more users.

So, you may want to unfollow some people you are following who are not following you back.

I use a tool called TweetAdder to help manage my Twitter followers. It helps me find users who are interested in my Tweets through targeted searches, and it also helps me unfollow users who are not interested in following me back.



And there's that.

Wednesday, June 29, 2011

Customize the favicon in your Blogger blog

How do you customize the favicon in your Blogger blog?
Very simple... in your template (Design -> Edit HTML), add the following 2 lines of code just before the closing </head> tag:

<link href='http://path-to-your-icon/favicon.ico' rel='shortcut icon' type='image/x-icon'/>
<link href='http://path-to-your-icon/favicon.ico' rel='icon' type='image/x-icon'/>

Replace path-to-your-icon with the path to your icon ;) For example, mine is at http://www.daveworld.net/favicon.ico.

Important to note:
1. put this just before the </head> tag so it counteracts the auto-generated favicon reference made by Blogger.
2. be sure to include the type='image/x-icon' part, or else this won't work in chrome.
3. Always back up your template first before making changes this way!

And there's that. Thoughts, comments, questions, feedback, criticisms... all welcome here, post below :)