• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

How to download audio files from URL links?

I am creating an app in which I have to play audio from a number of URL links. At the first ever run of the app I am providing user the option of either downloading all of the audio files at once. Right now I am downloading each URL individually using Async Task. The problem with this approach is that since I have some 6000 url links for audio files it takes very long.

My questions is that is there any way I can quickly download audio files from these 6000 urls or any better approach of handling downloads.

Below I am also providing the code that I am using for downloading each url.

public class DownloadAudio extends AsyncTask<Void, Void, String> {

public static final String TAG = DownloadAudio.class.getSimpleName();

ProgressDialog mProgressDialog;

Context context;
String stringUrl;
int index;

public DownloadAudio(Context context,String url, int randomNumber) {
this.context = context;

stringUrl=url;

index = randomNumber;

}

protected void onPreExecute() {
mProgressDialog = ProgressDialog.show(context, "Please wait", "Download …");
}

@override
protected String doInBackground(Void... voids) {
try {

URL url = new URL(stringUrl);
HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
String[] path = url.getPath().split("/");
int temp = path.length - 1;
String mp3 = path[temp];
int lengthOfFile = c.getContentLength();

String PATH = Environment.getExternalStorageDirectory()+ "/MyAudioApp/" ;
Log.v(TAG, "PATH: " + PATH);
File file = new File(PATH);
file.mkdirs();

String fileName = mp3;

File outputFile = new File(file , fileName);


FileOutputStream fos = new FileOutputStream(outputFile);

InputStream is = c.getInputStream();

byte[] buffer = new byte[1024];
int len1 = 0;
while ((len1 = is.read(buffer)) != -1) {

fos.write(buffer, 0, len1);
}
fos.close();
is.close();

} catch (IOException e) {
e.printStackTrace();
}

return "done";
}

protected void onPostExecute(String result) {
if (result.equals("done")) {
mProgressDialog.dismiss();
}
}

}

Please any suggestions would be very helpful.

Thanks​

To anyone using google calendar and the gtasks app...

When I found out about Tasks, and saw they integrated into Calendar, I was so excited it never even occurred to me that it wouldn't work on the phone. SURPRISE! So now all those "events" I had on my calendar to serve as reminders/tasks, which I removed and moved to Tasks, now have to be removed from Tasks and put back into Calendar. THANKS GOOGLE!

I also can find no widget in the Google Tasks app. So I'm assuming that's something else Google got rid of because it was too convenient for users.

And Google wants our company to move to Google Suite? I don't think so! Hell, I'm considering moving to an iPhone after this F-up!

And I noticed they put in a nice "Shopping List" as a pre-made task list that won't go away, and which has no integration whatsoever with the phone's shopping list function. You know, where you say, "Okay Google, add bread to my shopping list", and it does. So why does Tasks have a shopping list that's completely disconnected?

I think the Google Tasks team is off on their own world.

Problem with USB after drop

If you're repeatedly dropping your phone it's not surprising that various parts are failing. Panasonic has a Toughbook/Toughpad series of mobile devices designed to take some physical abuse:
https://na.panasonic.com/us/computers-tablets-handhelds/handhelds/handhelds
They're a bit pricier but weigh its cost to the total cost of buying a new phone and having it repaired on a regular basis (including the inconvenience of being without a phone each time its being serviced).

General Java discussion

Thanks for the suggestions!

Coderanch seems the most active, several posts just from today. DreamInCode seems ok but hasn't had a post in 2-3 weeks. That's still better than anything we've found so far.

By the way, were you able to get you're map app on the play store?

Thanks for asking!

Not quite yet, still getting those graphics wrapped up. Should be publishing this weekend. So far I've had pretty positive feedback (along with some good bug reports and feature suggestions) so I'm pretty happy. At least one of my testers is switching to my app over google maps! Can't complain about that!

App to get notification when you have voicemail?

You have the answer, yet you choose to ignore it... YouMail is not hard to setup and use... it will give you what you want, it will even notify you if the person does NOT leave a message so you aren't wondering if you're missing a message.

The "answer" repeatedly given was obviously not an answer to the problem as stated, which you choose to ignore.

ericsbcn said "I don't really want to set up a new... voicemail system." He just wanted a simple app that will show him when he has messages in his current voicemail system. YouMail apparently requires the user to switch to a new voicemail system. Not only that, but it has received many bad reviews, which specifically state that it's difficult or impossible to return to one's old voicemail system once you've installed YouMail.

I understand what ericsbcn was saying because I have the exact same issue. I want a simple app that will just show me how many unplayed and how many saved voicemails I have, without requiring me to switch to a different voicemail system. Even an app that would show me if I have any voicemails would be a step in the right direction. It's been nearly a decade since ericsbcn asked his question, and -- based on an extensive search -- there still appears to be no app that can competently handle the job that the cheapest answering machines were able to do over 3 decades ago.

Move apps to micro sd card

Some phones don't have that option, this might be the case on your phone. If you however want to store photos or other media you can change your default storing path for those. If you want to store ie. Spotify music on sd card you can just go to spotify settings and change storing device/location. As being said not all devices allow apps to be stored on sd, other media is more likely to be allowed.

- Jacob

Move to SD Card Greyed Out

I'm surprised you could move any third party app with your old phone, because this requires the developer to support it and many do not (increasingly so with many phones not having SD cards and Google dropping support for this feature back in Android 4 - it's been retained or added back by many manufacturers, but isn't a core feature of the OS any more). Hence I'd always expect there to be a significant fraction of user-installed apps that cannot be moved.

The one thing you could try is installing adb on your computer, enabling usb debugging on the phone, connect via USB, check adb is working and talking to your phone using the comment "adb devices", and if that finds the phone and responds use the command "adb shell pm set-install-location 2" - that sets the default to "install apps to SD". You'll have to move any you already have installed by hand, but it might fix whatever is blocking it.

How to increase image quality in android camera2 api

The only way you have to increase your image quality is increasing your ImageReaderSize to the biggest resolution:

Code:
mImageReader = ImageReader.newInstance(pictureSizeValue.getWidth(), pictureSizeValue.getHeight(), format, maxImages);

Also, you can improve the quality using the key CaptureRequest.JPEG_QUALITY in your CaptureRequest.

Java:
mCaptureRequestBuilder.set(CaptureRequest.JPEG_QUALITY, (byte) 100);

More: https://stackoverflow.com/questions...-using-camera-2-api-android/41809079#41809079
Yes Done it already.Any other Way

Attachments

  • Capture3.PNG
    Capture3.PNG
    53.1 KB · Views: 374

S Pen Motion Controls

Question, how does the S pen charge? Is it a stand alone charge device or does is pull it's charge from the phone. Never owning a Note, I'm completely ignorant about them. How are they secured in the device? Is manipulating the Note's screen and such by gesturing with the pen new or an older feature?
If if is something common on older Notes, how well do the gestures work? I guess I'm asking for a rundown on the pen... sorry. I need to know lots more about the pen before I'm convinced I need it. Thanks
it charges when it is in its cradle inside the phone. no need to worry about hooking it up or anything. as long as it is in the phone you are good to go.

it would be cool if the devs can make the s pen like a steering wheel so that we can play Need For SPeed or other car racing games.

or just in general....i'm interested what the devs will come up with the use of the gyroscope for the pen and how it reacts with their apps.

sorry forgot to mention about the s pen on the older devices. i like the note 8's feature where upon pulling thew s pen from its cradle right on the lockscreen a window pops up where you can immediately take notes. in the past you have to unlock first, pull the pen out, a menu pops up and you select notes and then you begin writing......too many steps for something immediate. i like the fact that they kept this feature in the note 10/10+

the s pen now with my note 8......does not have a battery so i do not have to worry about such things. it just sits nice and comfortable in its cradle in the phone. it is secured in its cradle. it is spring loaded so all you need to do is push on the pen and it will pop out.....not fly out pop just pops up and then you canj pull the pen out for use. when done you just put the pen inside the cradle and push it in to secure it.

Help Can images delete themselves?

i second using google photos....i never ever have to worry about losing my photos as they are automatically synced. i can go to any phone or pc and pull up my photos........provided that they have uploaded to cloud already.

and i have never heard of photos just randomly disappearing like that. like @Hadron said, unless it is an inadvertently done like in your pocket or something. have you tried hooking up the phone to the pc?

Filter

Back
Top Bottom