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 3155984dfa
commit 4ccd11ff4f
7 changed files with 45 additions and 8 deletions

View file

@ -22,6 +22,7 @@ package org.linphone.compatibility
import android.app.Notification
import android.app.NotificationManager
import android.app.Service
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.os.Build
@ -71,7 +72,11 @@ class Api34Compatibility {
intent.data = "package:${context.packageName}".toUri()
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
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")
}
}
}
}

View file

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

View file

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

View file

@ -283,7 +283,11 @@ class ContactFragment : SlidingPaneChildFragment() {
}
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) {
@ -299,7 +303,11 @@ class ContactFragment : SlidingPaneChildFragment() {
putExtra("address", number)
putExtra("sms_body", smsBody)
}
startActivity(smsIntent)
try {
startActivity(smsIntent)
} catch (anfe: ActivityNotFoundException) {
Log.e("$TAG Failed to start SMS intent: $anfe")
}
}
private fun showTrustProcessDialog() {

View file

@ -20,6 +20,7 @@
package org.linphone.ui.main.contacts.fragment
import android.Manifest
import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
@ -286,7 +287,11 @@ class ContactsListFragment : AbstractMainFragment() {
}
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) {

View file

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