Tuesday, March 15, 2011

Android Debugging, Start the Gallery App programmatically, decode/decompress AndroidManifest.xml

I just create one code snippet to save one Image from internet to SD card using the follow code, after that, I want to open the gallery app to view this Image.

URL url = new URL(address);
Object content = url.getContent();
InputStream is = (InputStream)content;

BufferedInputStream bis = new BufferedInputStream(is);
Bitmap bm = BitmapFactory.decodeStream(bis);
iv.setImageBitmap(bm); //bind to UI

String sdurl = Media.insertImage(getContentResolver(), bm, "pic1", null);
//url will be, content://media/external/images/media/29

How to Start the Gallery app and show this Image?

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData( Uri.parse(temp));


If you don’t know how to start a system activity, here is the trick, using the aapktool
basically, pull the apk from the Phone using the DDMS file browser plug-in, here I am pulling out the gallery apk located in /syste/app/*.apk

Download the extract the appktool. then run aapt.
here is the trick, all activity has the AndroidManifest.xml, in that xml, you can find all the declared intent filters to start this activity. By default , this file is compressed. so you need the appt tool to decompress it. here is how.

aapt dump xmltree Gallery3DGoogle.apk  AndroidManifest.xml >a.txt

then in the a.txt, you can see all the declared intent. I just pickup the view one.


No comments:

Locations of visitors to this page