AppLinksFragment: Wrap app link activity start in try-catch block
Android warns that it may not exist on all devices and samsung devices seems to prove that true. Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import android.content.pm.verify.domain.DomainVerificationUserState
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS
|
import android.provider.Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
@@ -19,6 +20,8 @@ import dagger.hilt.android.AndroidEntryPoint
|
|||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class AppLinksFragment : Fragment(R.layout.fragment_app_links) {
|
class AppLinksFragment : Fragment(R.layout.fragment_app_links) {
|
||||||
|
|
||||||
|
private val TAG = AppLinksFragment::class.java.simpleName
|
||||||
|
|
||||||
private var _binding: FragmentAppLinksBinding? = null
|
private var _binding: FragmentAppLinksBinding? = null
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
@@ -51,11 +54,16 @@ class AppLinksFragment : Fragment(R.layout.fragment_app_links) {
|
|||||||
if (isSAndAbove()) {
|
if (isSAndAbove()) {
|
||||||
buttons.values.forEach {
|
buttons.values.forEach {
|
||||||
it.setOnClickListener {
|
it.setOnClickListener {
|
||||||
val intent = Intent(
|
try {
|
||||||
ACTION_APP_OPEN_BY_DEFAULT_SETTINGS,
|
val intent = Intent(
|
||||||
Uri.parse("package:${view.context.packageName}")
|
ACTION_APP_OPEN_BY_DEFAULT_SETTINGS,
|
||||||
)
|
Uri.parse("package:${view.context.packageName}")
|
||||||
startForResult.launch(intent)
|
)
|
||||||
|
startForResult.launch(intent)
|
||||||
|
} catch (exception: Exception) {
|
||||||
|
Log.e(TAG, "Failed to open app links screen", exception)
|
||||||
|
toast(R.string.failed_app_link)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -400,4 +400,5 @@
|
|||||||
<string name="device_doze_extra">Optionally you can choose to keep the optimizations enabled, but then you won\'t be able to take benefit of background downloads and automated updates, so choice is yours.</string>
|
<string name="device_doze_extra">Optionally you can choose to keep the optimizations enabled, but then you won\'t be able to take benefit of background downloads and automated updates, so choice is yours.</string>
|
||||||
<string name="failed_apk_export">Failed to export APKs</string>
|
<string name="failed_apk_export">Failed to export APKs</string>
|
||||||
<string name="action_manage">Manage</string>
|
<string name="action_manage">Manage</string>
|
||||||
|
<string name="failed_app_link">Unsupported, please try associating links manually</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user