X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyCell.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Factivities%2FLogcatActivity.kt;fp=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Factivities%2FLogcatActivity.kt;h=ca396c233c010dadecc5d8721b9eee28b3982a03;hp=122ccc544364f1fe2b69108bb35c5d34f31fb57e;hb=e250fa01e1c6f079d040e0fdcb65434d20b138a4;hpb=9ee51bf9fbf3ef3e463456c4a4e4ef626eab3412 diff --git a/app/src/main/java/com/stoutner/privacycell/activities/LogcatActivity.kt b/app/src/main/java/com/stoutner/privacycell/activities/LogcatActivity.kt index 122ccc5..ca396c2 100644 --- a/app/src/main/java/com/stoutner/privacycell/activities/LogcatActivity.kt +++ b/app/src/main/java/com/stoutner/privacycell/activities/LogcatActivity.kt @@ -58,7 +58,7 @@ class LogcatActivity : AppCompatActivity() { private lateinit var logcatScrollView: ScrollView private lateinit var logcatTextView: TextView - // Define the save logcat activity result launcher. + // Define the save logcat activity result launcher. It must be defined before `onCreate()` is run or the app will crash. private val saveLogcatActivityResultLauncher = registerForActivityResult(ActivityResultContracts.CreateDocument()) { fileNameUri: Uri? -> // Only save the file if the URI is not null, which happens if the user exited the file picker by pressing back. if (fileNameUri != null) { @@ -82,7 +82,7 @@ class LogcatActivity : AppCompatActivity() { contentResolverCursor.moveToFirst() // Get the file name from the cursor. - val fileNameString = contentResolverCursor.getString(contentResolverCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)) + val fileNameString = contentResolverCursor.getString(contentResolverCursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME)) // Close the cursor. contentResolverCursor.close()