Pages

Sunday, July 31, 2011

Detecting Back Key press in Android

This post is moved to a different site! you will be redirected to the new location.

Opening a File Using Default Application in Android


Opening a File Using Default Application in Android
Here is the  code to do this


File file = new File("direcotry","fileName");
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "mimetype");
startActivity(intent); 

if you want to open a audio file code would look something similar to the following


File file = new File("direcotry","fileName");
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "audio/*");
startActivity(intent); 



using setDataAndType method would allow you to over rule the actual mime type of the file.

Saturday, July 9, 2011

JackRabbit Webdav method examples for WebDav client

This post has been moved to a different site. You will be redirected to the new location.

Friday, July 8, 2011

Access localhost of the computer from android emulator

Access localhost of the computer from android emulator

if you have tried to access localhost from android emulator using http://localhost or the ip address 127.0.0.1 , you would have seen an error message saying page not found. solution to this is to use 10.0.2.2 as the ip address for the localhost. you can access the localhost of your machine using this ip address.

you can see how socket are used to communicate with localhost and android emulator here.