Archive for February, 2010

How to create your own “Share” application for photos

This is alot easier to do than you might believe, it’s even so easy to do, that you might find it hard to find information about it in the documentation.

The main thing you have to do is to register your application to receive the SEND intent which is sent when clicking the “Share” button.

Add this to your Activity in the AndroidManifest.xml

<intent-filter>
   <action android:name="android.intent.action.SEND" />
   <data android:mimeType="image/*" />
   <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

Then you automatically get your application registered to the Sharing-list with the application name and icon, when selecting the application in the list, the activity will be launched and the photo is easily retreived through the launching intent.

final Intent intent = getIntent();
final Bundle content = intent.getExtras();
if ( content != null ) {
        //The uri below till contain an uri to the contentprovider
	final Uri uri = (Uri)content.getParcelable(Intent.EXTRA_STREAM);
 
        //if you want to know the filename of the image, just do a managedQuery 
        //against the projection MediaStore.Images.Media.DATA
}

2 Comments

How to pull and install the dev-apps to your Android device

The emulator and some Android developer devices have some small util applications which could be to some help if you’re developing an application for an Android device. Looking at your production phone will reveal that you don’t have those pre-installed, but it’s easy to get them from an emulator and then install them to your real phone.

These apps will let you change and/or simulate a non-existing locale, view stacktraces from log-files, more detailed information about battery-usage, and so on…

Start by navigating to the tools directory within your Android SDK, then execute the following commands after you’ve started your emulator:

adb -e pull /system/app/CustomLocale.apk CustomLocale.apk
adb -e pull /system/app/Development.apk Development.apk
adb -e pull /system/app/SpareParts.apk SpareParts.apk

That will retreive the packages for the three applications CustomLocale, DevTools and SpareParts from the connected emulator.

Then connect your device with the USB-cable if it’s not already plugged in and execute these commands from the same location:

adb -d install CustomLocale.apk
adb -d install Development.apk
adb -d install SpareParts.apk

Then you’ll have the three utils installed to your phone, ready to use.
Please note that everything might not work if you don’t have a real developer device, or running on a non-rooted device, some features might crash while trying to use them.

23 Comments