android program to copy music directory Himalayas

My Huawei cell phone (other Android phones should also be usable), built-in music player, Bluetooth can directly control playback stops. This feature is very convenient, especially do not want to dig the phone, press the play button Bluetooth car will be able to play, up and down keys can also switch songs. Open Huawei music - "Setting the Bluetooth control can also be directly controlled Bluetooth headset.

But the play control is Huawei's own music player, built-in music player and very few resources. And many are charging, Himalayan resources are very rich, so would be able to download audio Himalayas, copied to the music player just fine.

But the problem came, the Himalayan hidden directories deep. Every time it went very, very hard to find, and download the file name must also mess batch rename, rename and then copy the music catalog to Huawei.

I like to listen to some continuous program, do so every time a troublesome operation, I feel too much trouble. My lazy relapsed, write a program it. Function is very simple, is to enter the directory name, such as downloading the Three Kingdoms, Three Kingdoms in the input box will create a subdirectory of the Three Kingdoms in the Music directory, download a complete album, you can execute a program, copy the downloaded file past .

If the file does not copy the past, check to see whether there is a default Himalayan downloaded files directory

  • Found at the top of [my] interface [Setup] option and click

  • [Click Next to download and cache settings] -> [download location], where you can see the audio cache location.

Installation package can be downloaded via this link https://pan.baidu.com/s/1z6J6MvEeaCN590DhAlPvdA#list/path=%2Fshare%2Fmobile

Please refer to:

package com.youxr.jack.music;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Environment;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.system.Os;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import java.io.File;

public class MainActivity extends AppCompatActivity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final EditText keywordText = (EditText)this.findViewById(R.id.keyword);
        Button button = (Button)this.findViewById(R.id.button);
        final TextView result = (TextView)this.findViewById(R.id.result);


        button.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                String keyword = keywordText.getText().toString();
                if (keyword.equals("")) {
                    result.setText("请输入关键词!");
                }else {
                    result.setText(renameFile(keyword));
                }
            }
        });
    }

    //移动喜马拉雅下载的文件到另外一个目录
    private String renameFile(String keyword) {

        String result = "";
        String musicDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath();
        //源目录
        String src=System.getenv("EXTERNAL_STORAGE")+"/Android/data/com.ximalaya.ting.android/files/download";
        //目标目录
        String dst = musicDir+"/"+keyword.trim();
        File[] files = new File(src).listFiles();
        int i=0;
        //拷贝文件的目录,目录不存在创建一个目录
        File to = new File(dst);
        if(!to.exists()){
            to.mkdirs();
        }
        //按顺序重命名音乐文件
        for (File file : files) {
            i++;
            to = new File(dst,String.format("%03d", i)+".m4a");
            file.renameTo(to);
        }
        //判断拷贝结果
        if (i<1){
            result = "没有找到下载的文件!!";
        } else {
            result = String.format("共移动了 %d 个文件\n到 %s", i , dst);
        }

        return result;
    }
}

Download the installation package: https://pan.baidu.com/s/1z6J6MvEeaCN590DhAlPvdA#list/path=%2Fshare%2Fmobile

发布了67 篇原创文章 · 获赞 9 · 访问量 10万+

Guess you like

Origin blog.csdn.net/robinhunan/article/details/86423454