Added missing try/catch around some startActivity to prevent not found exceptions

This commit is contained in:
Sylvain Berfini 2025-11-21 16:31:00 +01:00
parent 1183a9e1c2
commit c496545023
7 changed files with 45 additions and 8 deletions

View file

@ -24,6 +24,7 @@ import android.app.Notification
import android.app.NotificationManager import android.app.NotificationManager
import android.app.PendingIntent import android.app.PendingIntent
import android.app.Service import android.app.Service
import android.content.ActivityNotFoundException
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build import android.os.Build
@ -74,7 +75,11 @@ class Api34Compatibility {
intent.data = "package:${context.packageName}".toUri() intent.data = "package:${context.packageName}".toUri()
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
Log.i("$TAG Starting ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT") Log.i("$TAG Starting ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT")
context.startActivity(intent, null) try {
context.startActivity(intent, null)
} catch (anfe: ActivityNotFoundException) {
Log.e("$TAG Failed to start intent for granting full screen intent permission: $anfe")
}
} }
fun sendPendingIntent(pendingIntent: PendingIntent, bundle: Bundle) { fun sendPendingIntent(pendingIntent: PendingIntent, bundle: Bundle) {

View file

@ -197,7 +197,11 @@ class FileViewerActivity : GenericActivity() {
} }
val shareIntent = Intent.createChooser(sendIntent, null) val shareIntent = Intent.createChooser(sendIntent, null)
startActivity(shareIntent) try {
startActivity(shareIntent)
} catch (anfe: ActivityNotFoundException) {
Log.e("$TAG Failed to start intent chooser: $anfe")
}
} else { } else {
Log.e("$TAG Failed to copy file [$filePath] to share!") Log.e("$TAG Failed to copy file [$filePath] to share!")
} }

View file

@ -1,5 +1,6 @@
package org.linphone.ui.fileviewer package org.linphone.ui.fileviewer
import android.content.ActivityNotFoundException
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import androidx.activity.enableEdgeToEdge import androidx.activity.enableEdgeToEdge
@ -269,7 +270,11 @@ class MediaViewerActivity : GenericActivity() {
} }
val shareIntent = Intent.createChooser(sendIntent, null) val shareIntent = Intent.createChooser(sendIntent, null)
startActivity(shareIntent) try {
startActivity(shareIntent)
} catch (anfe: ActivityNotFoundException) {
Log.e("$TAG Failed to start intent chooser: $anfe")
}
} else { } else {
Log.e( Log.e(
"$TAG Failed to copy file [$filePath] to share!" "$TAG Failed to copy file [$filePath] to share!"

View file

@ -283,7 +283,11 @@ class ContactFragment : SlidingPaneChildFragment() {
} }
val shareIntent = Intent.createChooser(sendIntent, null) val shareIntent = Intent.createChooser(sendIntent, null)
startActivity(shareIntent) try {
startActivity(shareIntent)
} catch (anfe: ActivityNotFoundException) {
Log.e("$TAG Failed to start intent chooser: $anfe")
}
} }
private fun inviteContactBySms(number: String) { private fun inviteContactBySms(number: String) {
@ -299,7 +303,11 @@ class ContactFragment : SlidingPaneChildFragment() {
putExtra("address", number) putExtra("address", number)
putExtra("sms_body", smsBody) putExtra("sms_body", smsBody)
} }
startActivity(smsIntent) try {
startActivity(smsIntent)
} catch (anfe: ActivityNotFoundException) {
Log.e("$TAG Failed to start SMS intent: $anfe")
}
} }
private fun showTrustProcessDialog() { private fun showTrustProcessDialog() {

View file

@ -20,6 +20,7 @@
package org.linphone.ui.main.contacts.fragment package org.linphone.ui.main.contacts.fragment
import android.Manifest import android.Manifest
import android.content.ActivityNotFoundException
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Bundle import android.os.Bundle
@ -333,7 +334,11 @@ class ContactsListFragment : AbstractMainFragment() {
} }
val shareIntent = Intent.createChooser(sendIntent, null) val shareIntent = Intent.createChooser(sendIntent, null)
startActivity(shareIntent) try {
startActivity(shareIntent)
} catch (anfe: ActivityNotFoundException) {
Log.e("$TAG Failed to start intent chooser: $anfe")
}
} }
private fun showFilterPopupMenu(view: View) { private fun showFilterPopupMenu(view: View) {

View file

@ -19,6 +19,7 @@
*/ */
package org.linphone.ui.main.recordings.fragment package org.linphone.ui.main.recordings.fragment
import android.content.ActivityNotFoundException
import android.content.Intent import android.content.Intent
import android.graphics.SurfaceTexture import android.graphics.SurfaceTexture
import android.os.Bundle import android.os.Bundle
@ -194,7 +195,11 @@ class RecordingMediaPlayerFragment : GenericMainFragment() {
} }
val shareIntent = Intent.createChooser(sendIntent, null) val shareIntent = Intent.createChooser(sendIntent, null)
startActivity(shareIntent) try {
startActivity(shareIntent)
} catch (anfe: ActivityNotFoundException) {
Log.e("$TAG Failed to start intent chooser: $anfe")
}
} }
} }
} }

View file

@ -19,6 +19,7 @@
*/ */
package org.linphone.ui.main.recordings.fragment package org.linphone.ui.main.recordings.fragment
import android.content.ActivityNotFoundException
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
@ -227,7 +228,11 @@ class RecordingsListFragment : GenericMainFragment() {
} }
val shareIntent = Intent.createChooser(sendIntent, null) val shareIntent = Intent.createChooser(sendIntent, null)
startActivity(shareIntent) try {
startActivity(shareIntent)
} catch (anfe: ActivityNotFoundException) {
Log.e("$TAG Failed to start intent chooser: $anfe")
}
} }
} }
} }