gpt4 book ai didi

android - APK 适用于三星,但在 Nexus 中出现 2 个错误?

转载 作者:行者123 更新时间:2023-11-30 00:34:28 25 4
gpt4 key购买 nike

在我的应用程序中,首先创建一个 NewFolder,然后我录制音频并将它们保存在这个新文件夹中。
我还有一个 ArrayList 来显示我的记录
我在这里创建 NewFolder

        int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
String sep = File.separator; // Use this instead of hardcoding the "/"
String newFolder = "FolderName";
String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
File myNewFolder = new File(extStorageDirectory + sep + newFolder);
//myNewFolder.mkdir();
myNewFolder.mkdirs();


while (fs.getfetchstatus() != true) {
mySongs = fs.findSongs(Environment.getExternalStorageDirectory());
//>>>>>>>>>>HERE IS HAVING ANY ERROR<<<<<<<<<


}
if (mySongs != null) {
dialog.dismiss();
}
mySongs = fs.getsonglist();

items = new String[mySongs.size()];
for (int i = 0; i < mySongs.size(); i++) {
items[i] = mySongs.get(i).getName().toString().replace(".3gp", "");

}
final ArrayAdapter<String> adp = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, items);
adp.notifyDataSetChanged();
lv.setAdapter(adp);

lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Intent intent = new Intent(getApplicationContext(), Player.class);
intent.putExtra("pos", i);
adp.notifyDataSetChanged();
startActivity(intent);
finish();
}
});

这是我的 ArrayList

     boolean fetchstatus=false;
ArrayList<File> songs=new ArrayList<File>();

String sep = File.separator; // Use this instead of hardcoding the "/"
String newFolder = "FolderName";
String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
File myNewFolder = new File(extStorageDirectory + sep + newFolder);

//File file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
FetchSongs(){

}
public ArrayList<File> findSongs(File root){

ArrayList<File> al=new ArrayList<File>();
// File[] files=root.listFiles();

//File file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File file = new File(Environment.getExternalStorageDirectory(), newFolder);
File[] files = file.listFiles();


for (File singleFile : files){
if(singleFile.isDirectory() && !singleFile.isHidden()){
al.addAll(findSongs(singleFile));
//>>>>>>>ERROR HERE<<<<<<<<<<<<<<<<<<<

}
else {
if(singleFile.getName().endsWith(".mp3")){
al.add(singleFile);
}
}
}

fetchstatus=true;
songs=al;
return al;

}

我有这些错误

     java.lang.RuntimeException: Unable to start activity ComponentInfo
at org.usr.usr.musicplayer.FetchSongs.findSongs(FetchSongs.java:35)
at org.usr.usr.musicplayer.MainActivity.onCreate(MainActivity.java:124)

最佳答案

也许只是这行错误

File file = new File(Environment.getExternalStorageDirectory(), newFolder);

Nexus 并不总是有外部存储,但为了更准确,您应该检查跟踪错误,很可能您能够看到导致运行时错误的确切行

关于android - APK 适用于三星,但在 Nexus 中出现 2 个错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43667448/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com