Archiv for ‘Android’


published: November 3rd, 2009

Is GPS on? If not prompt user to turn it on.

Here’s a quick code snippet to determine if the GPS is on, and if it isn’t go to the Setting screen allowing the user to turn it on.  Android does not allow a 3rd party app to automatically turn the GPS on/off as of 1.5, a “feature” discussed extensively on the Android Developers Forum.

(more…)

published: November 2nd, 2009

Searching for phone numbers with Android

I’ve been playing around with searching for contacts on the Android platform and thought I’d pass along a couple things I’ve learned.

One thing I’ve found out is that some of the classes from the books I’ve been using as reference have been deprecated.  Apparently, instead of using People.NUMBER, which has been deprecated for future support of multiple accounts, I should use the ContactsContact set of interfaces to get the contacts name and number.  Guess I’ll be upgrading to the Android 2.0 sdk sooner then I thought.  Although according to this forum thread the previous interfaces used to specify contact column, such as People, are still supported and will access contact information from the “primary” account.

Another cool thing I figured out was how to have the phone pad soft keyboard attached to an EditText widget.

device.png

It’s one of those, it was so easy I’m ashamed I didn’t know it, but then again, the SDK is large enough to where it’s hard to know ALL of it.  Anyway, all you need to do is define the “inputType” attribute value for the EditText widget which captures the phone number.

   	<EditText android:id="@+id/phone_nbr"
		android:layout_width="fill_parent"
		android:layout_height="wrap_content"
		android:inputType="phone"
		android:singleLine="true" />

Now, when the phone_nbr EditText box is entered, the phone pad comes up for data entry instead of the default Android soft keyboard.

There’s still many aspects of the Contacts API I haven’t investigated yet, but hopefully with the new apps I have the opportunity to work on, I’ll have lots of time to learn more about them.

published: October 27th, 2009

Note To Me re-branded as Message Drop

I’ve finally got Message Drop to a point where I feel it deserves a release.  Message Drop is a re-branding of Note To Me with a built in email client and a couple new features.  I’ll be getting screen shots up soon on the Message Drop page along with some more information, but just wanted to put the word.

There’s a trial version available, but if you find it useful I’d greatly appreciate it if you’d help my development effort and purchase the 1.99 version.  By the way, if you purchased Note To Me already, I’d be more then happy to refund your money if you email me an address that I can send the refund to.  I promise not to use your email for spamming!

I would greatly appreciate any comments you may have about Message Drop, Cheers!

published: October 22nd, 2009

AlertDialog for Android

Are you utilizing the full potential of AlertDialog?  I had no idea it was so versatile until I starting playing around with it recently.  I knew you could use it for a yes/no dialog for your mobile application, but I didn’t know it could also be an About dialog.  The API makes it really easy, although it doesn’t seem like the setPositiveButton() method is in the Android documentation.  The code snippet below cuts it down to the bare minimum.  It appears that a null can be passed instead of an empty OnClickListener and the action simply closes the window…which is the desired effect.

AlertDialog.Builder ad = new AlertDialog.Builder( this );
ad.setTitle( "About My Mobile Application" );
ad.setMessage( "This text explains My Mobile Application, thanks for " +
                       "purchasing it from the Android Market!" );
ad.setPositiveButton( "OK", null );
ad.show();

I’ve recently cleaned up a bunch of my code with this simple Dialog. And next I may have to look into the FrameLayout feature mentioned in the Android documentation.

published: October 21st, 2009

Android Freelancer looking for work

With the successful completion of my latest contracting gig, I find myself with the opportunity to investigate freelance work.  I’ve decided to take a couple of weeks to see if I can move into freelance development for the Android framework instead of looking for a full time position.  I have no idea if this will work and in the end I may have to start pushing my resume again, but I’m willing to try.  Don’t get me wrong, if the right opportunity for a full time position cames along, I’m certainly interested.

So, if you or someone you know needs a Android developer, I’d love to hear from you.  Email me at michael@mgmblog.com and I can send you my resume and let you know the initial rates I’m looking for.

Also, if you are currently freelancing (for either the Android or iPhone market) I’d be grateful to hear what has worked for you when it comes to looking for gigs or working with your clients.

published: October 17th, 2009

Some Mobile Links You May Have Missed

Here’s some links I still have laying around in my RSS reader I still need to get to, hopefully you may find some of them useful.

Development

5-Minute CSS Mobile Makeover from Perishable Press

I’m hoping there is some general WebKit info in Building iPhone Apps with HTML, CSS, and JavaScript by Jonathan Stark

General Mobile Information

Haven’t had a chance to read Developing Games for Android from Gamasutra, looks like some good information about the business side of game development on the Android platform.

Justin Pratt does an awesome job breaking down the numbers in his article Earning a Living as an Independent Mobile Software Developer

Core Values: The silicon Behind Android from Engadget

Bonus

OK, not about mobile development specifically, but it’s easy to get discouraged during development…

How to Defeat Burnout and Stay Motivated  from Zen Habits

published: October 11th, 2009

Email via Android Intent code snippet

I’m moving away from using the Android email client in Note To Me, but wanted to share the snippet to launch the client.  And who knows, maybe I’ll add it back in if people want it as an option.

        Button sendBtn = (Button) findViewById(R.id.send_btn_id);
        sendBtn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v)
            {
            	Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            	emailIntent.setType("text/html");
            	emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                  new String[]{ sendToAddress } );

            	emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject );
            	emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, msg );

            	hideKeyboard();

            	NoteToMe.this.startActivity(emailIntent);
            	NoteToMe.this.finish();
            }
        });

published: October 8th, 2009

I can handle these numbers

I know this is just fanciful dreaming, and this sort of thinking is one reason for the internet bubble in the late 90’s and burst in early 2000…but it’s fun anyway!

Given the following numbers

  • According to Engadget the Android market share could hit 14% by 2012
  • Current number of smart phones world wide is 235.6 million according to this article from Yahoo
  • Android’s market share is currently less then 2% (according to the Engadget article)

I think I can safely make the following pessimistic calculation:

(more…)

published: October 4th, 2009

MediaDroid “mostly” working with Android 1.6

* UPDATE - Full and Trial version of MediaDroid now have fixes for Android 1.6 layout issues I was having.  Check them out in the Android Market and let me know what you think!

Just got updated to 1.6 from T-Mobile. I love the new searching capabilities and the Power Control Home screen Widget.

homescreen_widgets.png

But it looks like I have some work to be done for one of the layouts for MediaDroid.  Not sure what’s wrong yet, but it looks like the layout for the Manage Album screen isn’t configured correctly and the buttons have been force out of the screen.  Hopefully the fix isn’t to hard and I’ll get a new version of MediaDroid out soon!

mange_album_16oops.png

published: October 1st, 2009

MediaDroid now cycles images from the selected album

Using a Service and ACTION_SCREEN_OFF  I’ve successfully added a new feature to MediaDroid which cycles the images in your photo album.  Every time the screen is put to sleep, the next photo in the album is placed in the photo widget on the Home screen of your Android device.  Here’s a code snippet…

public class ChangeImageService extends Service
{
	private static final boolean LOGD = Constants.LOGD;

	private BroadcastReceiver _receiver;
	private static final String LOG_TAG = "ChangeImageService";

        @Override
	public void onCreate()
        {
		super.onCreate();

	    _receiver = new BroadcastReceiver()
	    {
	        public void onReceive(Context context, Intent intent)
	        {
	        	loadNextImage();
	        }
	    };

	    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
	    registerReceiver(_receiver, filter);
	}

....
}

A couple of gotchas you have to watch out for… The ACTION_SCREEN_OFF Intent does not get picked up from the AndroidManifest.xml file so you have to assign it in code as shown above.  Also, I put the assignment in the onCreate method because the Service can get killed off.  If the Service is killed off, Android will schedule it to restart, but in order to catch the Screen Off broadcasts the Service must sign up again in the onCreate method…at least, this is what worked for me and all seems to be going well.  As always, the docs are a little sparse and I had to go through some trial and error to figure it out, but I’m pretty happy with the results.

The new feature (along with a bug fix) is available in both the Trial and Full version of MediaDroid in the Android market…check em out and let me know what you think!