2

I tried below code to start downloading an mp3 file in android, it was right until this morning, now it throws this exeption android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat= http://snd.tebyan.net/1388/03/Baz Amadam55055.mp3 }both in emulator and real device, I did not change the code, what happened? what is wrong?

String url = " http://snd.tebyan.net/1388/03/Baz Amadam55055.mp3";
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
asked Feb 26, 2014 at 15:43

3 Answers 3

3

Try removing the space before http in your string:

String url = "http://snd.tebyan.net/1388/03/Baz Amadam55055.mp3";
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
Aleks G
57.5k34 gold badges180 silver badges280 bronze badges
answered Feb 26, 2014 at 15:45
Sign up to request clarification or add additional context in comments.

Comments

3

As Hariharan and Artoo pointed out, there are several bugs in the piece of code

There is a space in string url. Change it to String url = "http://snd.tebyan.net/1388/03/Baz Amadam55055.mp3";.

Moreover, you can't pass a String to start an intent. Convert it to a Uri object and then pass it to the Intent constructor. That is probably the line you accidentally deleted. Add the line Uri uri = Uri.parse(url) to your code. The final solution is something like:

String url = "http://snd.tebyan.net/1388/03/Baz Amadam55055.mp3";
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

One last point is that the particular Url requires your emulator/device to contain an SD card. Go through your emulator's details and check if SD card is ticked and has a reasonable size in MB.

answered Feb 26, 2014 at 15:59

Comments

1
String url = " http://snd.tebyan.net/1388/03/Baz Amadam55055.mp3";
Intent intent = new Intent(Intent.ACTION_VIEW, uri);

Here you're using two different names: uri != url...

And, as Hariharan said, there's an extra space in the uri (here called "url") definition.

answered Feb 26, 2014 at 15:53

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.