Android Development

A place to discuss Android Development, Eclipes, the SDK, Java, xml and souch issues.

Not able to play Notification audio file (sound) (SDK m3-rc37a)


I am trying to play a audio file (ring tone) for an notification, for that I set Notification.sound property to an content URI of a file. Like this

ContentURI fileURI = ContentURI.Create(audioFile); // audioFile is of type File.
notification.sound = fileURI;

NotificationManager.notify(ID, notification);

But I am getting following error in the logcat:

W/NotificationMgr( 472): error loading sound for file:///system/media/audio/ringtones/em_ringtone1.mp3

Am I doing anything wrong? Please help.

I am using SDK m3-rc37a.


Application hangs for continuous running service


I am implementing a service that need to do certain activity periodically.

So for continuous the doing the activities I am using infinite loop (while(true) ) but also waiting for some time using thread.sleep().

Something like this

while(true) {

.... (some functionality)


I am doing this in service onStart function. but because this type of continuous operations the application screen is getting hanged.

Please help.


Weird map issues.

Has anyone been getting weird problems when using the map? Ive written my own map activity based on the TourGuide tutorial.

The things Ive noticed are:

- Sometimes when I load a new location (from the slider), it will take a LONG time to load the map. It can also take forever; and never load.

- Using TourGuide tutorial as a template, Ill make the slightest changes to the coordinates of a site. The site wont load once i make changes.

I modified the locations string as follows. For the museum string, all i did was copy the WTC string and change two digits of the lat/lon coordinates. (This should make museum a location somewhere nearby the WTC in Manhattan). The problem is, when I select museum in the slider, a map doesn't load and X's show up everywhere.

private String[][] locations = {
{ "WTC", "-74.012253,40.711641" },
{ "Museum", "-73.512253,40.461641" },
{ "Vegas Strip", "-115.162296,36.133347" }

Any ideas why this is happening?

note: All of the points that I dont change will work fine.

Android File System : How to Read a local file

Hello everybody!
(hi dr. nick!)

I have been able to successfully parse a XML file from an internet URL using SAX parser. Now im looking to change my code to be able to parse a local XML file. Below is a part of the code I am using.

My problem could be due to syntax or it could be do to a lack of understanding on how the Android file system works.

// ----------------------------------

FileInputStream fstream = null;
try {
fstream = new FileInputStream(filename);

/* Get a SAXParser from the SAXPArserFactory. */
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
/* Get the XMLReader of the SAXParser we created. */
XMLReader xr = sp.getXMLReader();
/* Create a new ContentHandler and apply it to the XML-Reader*/
ExampleHandler myExampleHandler = new ExampleHandler();
xr.parse(new InputSource(fstream));
// more code......
}catch (Exception FileNotFoundException){
Log.v(logCat, "File not found exception!:" + filename);

// ------------------------------------------

A file not found exception is getting thrown so im thinking that the problematic code is this line:

fstream = new FileInputStream(filename);
// filename = "/res/xml/sample.xml"

Does that file path make sense to use for accessing a file local to this application? ie. / is where my project is stored, /src is where the source files are located, /res/layout is where the layout files are. I created the /res/xml directory

Thats a long post. Hopefully i made my problem clear.

Thanks, daniel

Control size of widget

Hey all.
Im going through the tutorial of the VirtualTour. It uses the spinner widget to display locations. I wanted to modify the example and make the spinner box shorter. Right now, the width of the box seems to be determined by the length of the longest string inside of it.

Is there a way to force the spinner to be a fixed width?

From main.xml:

Changing android:layout_width="wrap_content" to android:layout_width="50px" does not have any effect on it's width.


How to receive Message using XMPP


I am using XMPP to simulate communication between two emulators instances, sending data and command.

Program need to receive the message command and act accordingly.

But I am not able to receive the message.

I refer to following link

But the code on the link does not receive the message. The Adapter gets updated dynamically. I need to analyze the last message received.

Please help.


Communication between two emulator instances


I am developing an application on android platform which include bluetooth communication. But since the bluetooth is yet not supported, what is the best way to communicate between two emulators to simulate bluetooth communication.

Please help.


I am looking for an Android developer

We are based in the SF Bay Area

I am looking for an Android developer to help us get our project together in the next 8 weeks
email me at

How do you pause sound?

How would you create and play a MediaPlayer when pushing a button using code like this:

MediaPlayer mp = MediaPlayer.create(context, R.raw.song1);

and then pause that sound using another button? In other words, how can you call on the MediaPlayer "mp" from a public void other than the one it was created in?

upload files from android to web Server

Hi to all, Sorry for the post in first page.

Can you any one tell me , how to upload file from android to web server.
Using following php code and android code, I can send data from android to web server. i don't know how to upload files.

php Code.


$target_path = basename( $_FILES["uploadedfile"]["name"]);
if(move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], $target_path)) {
echo "The file ".basename( $_FILES["uploadedfile"]["name"])." has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
echo _POST('data'

android Code.

HttpClient client = new HttpClient();
HttpMethod method = new PostMethod(""

catch (Exception e)

Can you anyone help me to solve this problem.



Syndicate content