From a90ef44f6c95e69b8518ebded6e0f562a05a79fa Mon Sep 17 00:00:00 2001 From: kun1h Date: Sun, 4 Feb 2024 17:48:53 +0800 Subject: [PATCH] fix bug --- app/src/main/AndroidManifest.xml | 6 +- .../java/com/bing89/travebing/MainActivity.kt | 81 ++++++++++--------- 2 files changed, 46 insertions(+), 41 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 99a9930..f15eae7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,10 +7,8 @@ - - + + >>> get location from gps") locMan.requestLocationUpdates(provider, 10000L, 100f, locationListener) } catch (ex: SecurityException) { @@ -296,13 +295,19 @@ class MainActivity : AppCompatActivity() { /** * 单个文件复制 */ - fun copyfile(srcFile: InputStream, destFile: File) { + private fun copyFile(srcFile: InputStream, destFile: File):Long { val fos = FileOutputStream(destFile) - srcFile.copyTo(fos) - fos.close() - srcFile.close() - } + val n = srcFile.copyTo(fos) + try { + fos.close() + srcFile.close() + }catch (e: java.io.IOException){ + Log.d(TAG, "================>>>>> copy failed") + } + + return n + } private fun takePhoto(): String { // Get a stable reference of the modifiable image capture use case val imageCapture = imageCapture ?: return "" @@ -338,7 +343,9 @@ class MainActivity : AppCompatActivity() { override fun onImageSaved(output: ImageCapture.OutputFileResults) { previewImageView.setImageURI(output.savedUri) val msg = "--------- Photo capture succeeded: ${output.savedUri}" - Toast.makeText(baseContext, msg, Toast.LENGTH_SHORT).show() +// Looper.prepare() +// Toast.makeText(baseContext, msg, Toast.LENGTH_SHORT).show() +// Looper.loop() Log.d(TAG, msg) val resolve = context.contentResolver val uri = Uri.withAppendedPath(output.savedUri, "")