我们的团队本周正在创建一个聊天机器人应用程序。我们完成了AIML文件的编码以及Android Studio中的主要代码。我们现在唯一的问题是这两者之间的联系。
我已经将Ab.jar放在了libs文件夹中。另外,我已将AIML文件放在资源文件夹中。
我认为与链接相关的代码如下(来自ChatActivity.class):
final String name = "Phil";
final int value = 341;
final int hours = value / 60;
final int minutes = value % 60; // modulo
System.out.printf("%-20s: %dh%02dm%n", name, hours, minutes);
//checking SD card availability
boolean a = isSDCARDAvailable();
//receiving the assets from the app directory
AssetManager assets = getResources().getAssets();
File seedletDir = new File(Environment.getExternalStorageDirectory().toString() + "/bots/seedlet");
boolean b = seedletDir.mkdirs();
if (seedletDir.exists()) {
//Reading the file
try {
for (String dir : assets.list("seedlet")) {
File subdir = new File(seedletDir.getPath() + "/" + dir);
boolean subdir_check = subdir.mkdirs();
for (String file : assets.list("seedlet/" + dir)) {
File f = new File(seedletDir.getPath() + "/" + dir + "/" + file);
if (f.exists()) {
continue;
}
InputStream in = null;
OutputStream out = null;
in = assets.open("seedlet/" + dir + "/" + file);
out = new FileOutputStream(seedletDir.getPath() + "/" + dir + "/" + file);
//copy file from assets to the mobile's SD card or any secondary memory
copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
当我运行应用程序并开始与机器人聊天时,机器人错误地回复了#34;我没有答案#34;
我该如何解决这个问题?
答案 0 :(得分:0)
将这两个权限添加到清单文件
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />