当我从Android Studio安装我的应用时,效果很好但是当我使用adb install <pc path to apk>
或adb shell pm install -r <device path to apk>
进行安装时,该应用无法将文件写入设备文件系统......
有谁知道为什么?有什么区别?用adb安装不会给应用程序提供它想要的权限吗?
谢谢!
修改
try {
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element root = doc.createElement("map");
doc.appendChild(root);
buildCamCapabilitiesXML(cm.getCameraCharacteristics(cameraID), doc, root);
writeXMLToFile(doc);
renameFileAndDeleteOldOne(storagePath + fileName, new File(storagePath + fileName + FILE_TEMP_EXTENSION));
} catch (CameraAccessException e) {
e.printStackTrace();
Log.e(TAG, "Failed to access camera to get camera abilities");
} catch (ParserConfigurationException e) {
e.printStackTrace();
Log.e(TAG, "Failed to get a DocumentBuilder");
} catch (TransformerException e) {
e.printStackTrace();
Log.e(TAG, "Failed to write capabilities xml file to filesystem");
}
private void writeXMLToFile(Document doc) throws TransformerException {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
transformer.transform(new DOMSource(doc), new StreamResult(new File(storagePath + fileName + FILE_TEMP_EXTENSION)));
}
答案 0 :(得分:0)
解决了它。
显然,应用程序必须在adb安装后从设备启动一次(在Android Studio中自动完成)。
之后它完美无缺,但不知道为什么......