mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Prevent crash if fails to go to outside activity because it doesn't exists or it isn't found
This commit is contained in:
parent
4b9ca10192
commit
6210ecb520
3 changed files with 35 additions and 19 deletions
|
|
@ -20,6 +20,7 @@
|
|||
package org.linphone.ui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
|
|
@ -40,6 +41,7 @@ import org.linphone.LinphoneApplication.Companion.corePreferences
|
|||
import org.linphone.R
|
||||
import org.linphone.compatibility.Compatibility
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.main.settings.fragment.SettingsFragment
|
||||
import org.linphone.utils.ToastUtils
|
||||
import org.linphone.utils.slideInToastFromTop
|
||||
import org.linphone.utils.slideInToastFromTopForDuration
|
||||
|
|
@ -224,15 +226,19 @@ open class GenericActivity : AppCompatActivity() {
|
|||
|
||||
fun goToAndroidPermissionSettings() {
|
||||
Log.i("$TAG Going into Android settings for our app")
|
||||
val intent = Intent(
|
||||
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||
Uri.fromParts(
|
||||
"package",
|
||||
packageName, null
|
||||
try {
|
||||
val intent = Intent(
|
||||
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||
Uri.fromParts(
|
||||
"package",
|
||||
packageName, null
|
||||
)
|
||||
)
|
||||
)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
} catch (anfe: ActivityNotFoundException) {
|
||||
Log.e("$TAG Failed to go to android settings: $anfe")
|
||||
}
|
||||
}
|
||||
|
||||
protected fun enableWindowSecureMode(enable: Boolean) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
package org.linphone.ui.main.contacts.fragment
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
|
|
@ -170,11 +171,15 @@ class ContactFragment : SlidingPaneChildFragment() {
|
|||
|
||||
viewModel.openNativeContactEditor.observe(viewLifecycleOwner) {
|
||||
it.consume { uri ->
|
||||
val editIntent = Intent(Intent.ACTION_EDIT).apply {
|
||||
setDataAndType(uri.toUri(), ContactsContract.Contacts.CONTENT_ITEM_TYPE)
|
||||
putExtra("finishActivityOnSaveCompleted", true)
|
||||
try {
|
||||
val editIntent = Intent(Intent.ACTION_EDIT).apply {
|
||||
setDataAndType(uri.toUri(), ContactsContract.Contacts.CONTENT_ITEM_TYPE)
|
||||
putExtra("finishActivityOnSaveCompleted", true)
|
||||
}
|
||||
startActivity(editIntent)
|
||||
} catch (anfe: ActivityNotFoundException) {
|
||||
Log.e("$TAG Failed to open native contact editor with URI [$uri]: $anfe")
|
||||
}
|
||||
startActivity(editIntent)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
package org.linphone.ui.main.settings.fragment
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
|
|
@ -144,14 +145,18 @@ class SettingsFragment : GenericMainFragment() {
|
|||
viewModel.goToIncomingCallNotificationChannelSettingsEvent.observe(viewLifecycleOwner) {
|
||||
it.consume {
|
||||
Log.w("$TAG Going to incoming call channel settings")
|
||||
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS).apply {
|
||||
putExtra(Settings.EXTRA_APP_PACKAGE, requireContext().packageName)
|
||||
putExtra(
|
||||
Settings.EXTRA_CHANNEL_ID,
|
||||
getString(R.string.notification_channel_incoming_call_id)
|
||||
)
|
||||
try {
|
||||
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS).apply {
|
||||
putExtra(Settings.EXTRA_APP_PACKAGE, requireContext().packageName)
|
||||
putExtra(
|
||||
Settings.EXTRA_CHANNEL_ID,
|
||||
getString(R.string.notification_channel_incoming_call_id)
|
||||
)
|
||||
}
|
||||
startActivity(intent)
|
||||
} catch (anfe: ActivityNotFoundException) {
|
||||
Log.e("$TAG Failed to go to notification channel settings: $anfe")
|
||||
}
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue