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)

Hi,

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.

Regards,
Prashant

Application hangs for continuous running service

Hi,

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)

Thread.sleep(5000);
}

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

Please help.

Regards,
Prashant

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.setContentHandler(myExampleHandler);
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.

Thanks,
daniel

How to receive Message using XMPP

Hi,

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
http://davanum.wordpress.com/2007/11/23/totally-unofficial-android-gtalk...

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.

Regards,
Prashant

Communication between two emulator instances

Hi,

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.

Regards,
Prashant

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 clifforloff@alum.mit.edu

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);
mp.prepare();
mp.start();

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.

<?php

$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.

try
{
HttpClient client = new HttpClient();
HttpMethod method = new PostMethod("http://webserver.com/data.php?data=myData"

client.executeMethod(method);
a.setText("Ok"+method.getResponseBodyAsString());
method.releaseConnection();
}
catch (Exception e)
{
a.setText("Error"
}

Can you anyone help me to solve this problem.

Regards,
Venkat

?>

Syndicate content