• 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​

WiFi drops every couple of minutes

I have the Note 9 with magisk latest the only problem I have is that my WiFi has a exclamation mark next to it and I don't get any connection. I only have WiFi on not mobile data. I have to reconnect again to make it work it happens every couple of minutes. I just downloaded the ROM and the vendor fix when flashing. Any help? I have The Galaxy Project ROM

https://forum.xda-developers.com/galaxy-note-9/development/rom-galaxy-project-t3911947

Attachments

  • SmartSelect_20190813-164101_YouTube.jpg
    SmartSelect_20190813-164101_YouTube.jpg
    3.2 KB · Views: 174

Help Internal Storage Data Migration Question

After reformatting a 32GB micro SD card as a internal storage, I had my phone move over some apps and migrate any music/videos I had on the phone's internal storage. Seeing that I had plenty of leftover space, I decided to put on some more music/videos, but according to the phone it seems that these new files are being copied over to the phone's storage as opposed to the SD card.

So I figured I'd have to use the same 'migrate data' operation, only to find that this option was nowhere to be found. Instead, I found this option located on the phone's internal storage, where I was prompted to move the files from the SD card back to the phone, which isn't at all what I intended. But given the current observed behavior, I humored the operation, and checked back to the SD card options upon completion. There, I found the data migration option once again.

Given what I've observed thus far, it seems that in order to utilize the vast amounts of space on this SD card as additional app and music/video storage, I must migrate the latter all at once, which more or less limits the amount of space I can use to whatever free space I can create on the phone's internal storage.

Is there some other way to move files from my phone's internal storage over to the formatted SD card without going through this terribly restrictive migration process?

Help Sonim XP8800 Bluetooth pairs to radio but no audio?

My Sonim XP8800 (not a common device, I know) pairs via Bluetooth to other devices (such as my Amazon Echo) with no problem, plays audio from phone calls, any media source, etc... No matter what I try it will not play audio through the stereo (Kenwood DPX303MBT) in my truck. I've tried changing settings, resetting the device, using different audio apps (Youtube, Pandora, Spotify, etc...) and no matter what, the device pairs, and the data (Pandora channel, song title, etc...) shows on the stereo display, but I get no audio from the stereo or the phone. My other phone, an old Samsung Note plays audio through the same stereo with no issue. I called tech support for both the phone and the stereo to try to resolve the issue to no avail. I did find out from Kenwood that the stereo is running Bluetooth version 3.0-not sure if that means anything. Any suggestions?

My cat is sick

My beautiful, favorite cat, Joy Noelle, is sick. :(

Yesterday I happened to be passing by one of the rooms that has a litter box--and she was peeing on the mat, not in the box. I just stood there gaping at her; she never potties outside a cat box.

She finished peeing and sat down a few inches away. She didn't know I was behind her. I called out to her, "Joy...Joy Noelle?", and she looked at me and groaned "mmmmmmm"

I scooped her up and took her to my room; she was moaning the whole time. The minute my live-in helper got home I told her; I was almost in tears.

We had both noticed things recently, like being able to feel her hip-bones. We had made an appointment with my vet--who my helper used to work for--for her regular checkup next Tuesday. But we called and they said to bring her in right away.

My vet gave her 100cc of fluids (she was dehydrated), and drew blood and urine for a full lab panel. He sent us home with antibiotics, and will call when the lab results are in. We're all thinking renal failure...but maybe we're wrong, and it's just a little bladder infection.

Here's a recent pic of her sleeping on her favorite piece of furniture: me!

xScreenshot_20190806-143749.jpg


Please send prayers, healing thoughts, whatever your thing is, our way. I've had her since she was ≈5 weeks old, and she'll turn 15 in October. I adore her...

Moto G7 Plus fingerprint security

Really pleased with my new dual SIM Moto G7 Plus although I have a question with regard to the fingerprint access.
When I activate the phone with my fingerprint it will then require my pin number before reaching the home screen, on my previous G5 Plus the fingerprint would take me to my home screen.
Is this an additional security measure or could it be setup without the pin number as well?
I have spent sometime trying!

Alan

Problem with USB after drop

So I got the phone to a store (not official HTC service) to change the screen and the back glass because I was quite careless with it. The guy changed them but I have some problems with it. First of all the mic during the calls and the voice recorder app doesn't work (the other mics work) and the most important, after dropping it again after the repair
angel.gif
the phone charges only slowly and also the pc doesn't recognize it anymore. I will open it sooner or later to see if there are some cables that are loose but what would potentially need to be changed on the inside for the pc to recognize it again. Thank you friends!!
biggrin.gif

Help emails disappear

I have an LG Aristo 2 . My problem is when I pull up my emails it only show and keeps 2 days worth. The rest just disappear after 2 days on the screen? I have no idea how to keep e mails for more than 2 days. They automatically just go to trash???
How do I keep my emails on my INBOX screen unless I choose to delete them..THXS

Smart Switch

So, on my note 8 I am having an issue where I am dropping bluetooth in the middle of calls, regardless of what BT device I'm using. They suggested I backup with Smart Switch, kinda like in old rooting/rom days when you could backup a rom, i guess .. ish.

So, If the problem remains, they send me an extended warranty replacement, but at least i have the backup. I hate having to redo EVERYthing. Here goes nothing.

Downloaded PDF files

Good afternoon or evening,



I would like to know if it is possible to move PDF documents or files that you have downloaded onto your phone. These items are currently under the following section of my S10+. My Files >> Documents / Downloads.

Is it possible to move these files from this section into a folder on the home screen. I just hate the fact i need to go to the above location each time i want to get to one of my pdf documents or to search my phone for them.

Again any help much appreciated.

Kind Regards
Sohail187

AUX Cable?

I'm trying to use my Honor 5X to play music through my car's speakers. I bought a micro-sd card and put it in my Honor 5X, thanks to GamerCore's very helpful instructions found on this forum. I was even able to upload music to the micro-sd card by following a thread elsewhere on this forum.

Unfortunately, there's no music coming out of my car's speakers no matter what cable (AUX or USB) I use to connect my Honor 5X to the car. I'm thinking that the problem lies with the Honor 5X automatically thinking that anything plugged into the AUX hole is a headset. Am I on the right track, and if so, is there anything I can do to stop this from happening?

=>Donna

Advice on Learning Programming Android Apps

I would appreciate if someone can someone can give me advice on the best way to learn Programming Android Apps.

I started learning Android Studio and know my way around to do simple apps but I would like to learn more complex apps including linking to a msql database.

Should I rather learn Java Programming first (as my knowledge is very basic) before continuing with Android Studio or should I just learn as I go along.

Also is it better to learn Kotlin or Java as I have no experience in either.

Thank you

Gradle DSL method not found: 'testImplementation()' when creating a separate test module

I do according to this instruction:https://developer.android.com/studio/test#use_separate_test_modules_for_instrumented_tests
After I replaced apply plugin: 'com.android.library' with apply plugin: 'com.android.test' I got this error:
Code:
ERROR: Gradle DSL method not found: 'testImplementation()'
Possible causes:
The project 'app5' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.4.2 and sync project

The project 'app5' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file

The build file may be missing a Gradle plugin.
Apply Gradle plugin
No actions that the studio offers naturally work. What to do?

Help How to stop update notifications

Hello everybody. I have a Lenovo k8 plus. It is almost a perfect phone except for one thing: it constantly keeps on showing me update notifications about 50-60 times a day full screen. It draws over other apps and many times interrupts and causes problems with other apps that were running...

It is very annoying and I have no idea how to disable these full screen notifications. Any help?

Rooting

OK guys I know it must be possible to root a Samsung Tab A (2019), but can find no useful info but searching, most that I find relates to earlier models running earlier versions of Android - my tab is on 9.0. Any advice on where to find a decent guide would be most appreciated.....

Apps What is a problem in your life that a mobile app would solve?

Hey there!

I'm a university student at Queensland University of Technology (QUT). My degree is in Information Technology (Computer Science), and one of the firsts assignments I'll be doing is developing the front-end of a mobile application with my group.

Part of the assignment is to find problem spaces for our mobile application by asking members of the public, so here I am!

If anyone is interested, I'll happily share the progress of the mobile app that my team and I work on once we decide on a problem space to tackle, and I'd also open the testing of the front-end to anyone willing to follow the required conditions of the testing!

I look forward to reading your responses.

Filter

Back
Top Bottom