Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application crash management #88

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/src/main/java/com/aws/amazonlocation/AmazonLocationApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import android.app.Application
import androidx.appcompat.app.AppCompatDelegate
import com.aws.amazonlocation.ui.main.CrashListener
import com.aws.amazonlocation.utils.AmplifyHelper
import com.aws.amazonlocation.utils.KEY_APP_CRASH
import com.aws.amazonlocation.utils.PreferenceManager
import dagger.hilt.android.HiltAndroidApp
import javax.inject.Inject
import kotlin.system.exitProcess

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

Expand All @@ -16,6 +17,8 @@ class AmazonLocationApp : Application() {

@Inject
lateinit var amplifyHelper: AmplifyHelper
@Inject
lateinit var mPreferenceManager: PreferenceManager
private var crashListener: CrashListener? = null

override fun onCreate() {
Expand All @@ -25,9 +28,8 @@ class AmazonLocationApp : Application() {
}
private fun setupUncaughtExceptionHandler() {
Thread.setDefaultUncaughtExceptionHandler { _, throwable ->
mPreferenceManager.setValue(KEY_APP_CRASH, true)
notifyAppCrash(throwable.message)
zeeshanmakeen marked this conversation as resolved.
Show resolved Hide resolved
android.os.Process.killProcess(android.os.Process.myPid())
exitProcess(1)
}
}
fun setCrashListener(listener: CrashListener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ class MainActivity : BaseActivity(), CrashListener {
val languageCode = getLanguageCode()
languageCode?.let { setLocale(it, applicationContext) }
}
val isAppCrashed = mPreferenceManager.getBooleanValue(KEY_APP_CRASH, false)
if (isAppCrashed) {
mPreferenceManager.setValue(KEY_APP_CRASH, false)
appCrashedDialog()
}
}

// check rtl layout
Expand Down Expand Up @@ -967,6 +972,7 @@ class MainActivity : BaseActivity(), CrashListener {
)
analyticsHelper?.recordEvent(EventType.APPLICATION_ERROR, properties)
}
restartApplication()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const val KEY_MAP_NAME = "key_map_name"
const val KEY_MAP_STYLE_NAME = "key_map_style_name"
const val KEY_GRAB_DONT_ASK = "key_grab_dont_ask"
const val KEY_OPEN_DATA_DONT_ASK = "key_open_data_dont_ask"
const val KEY_APP_CRASH = "key_app_crash"
const val CLICK_DEBOUNCE = 1000L
const val CLICK_DEBOUNCE_ENABLE = 1200L
const val RESTART_DELAY = 800L
Expand Down
14 changes: 13 additions & 1 deletion app/src/main/java/com/aws/amazonlocation/utils/DialogUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,18 @@ fun Context.changeDataProviderDialog(
mDialog.show()
}

fun Context.appCrashedDialog() {
val mDialog = MaterialAlertDialogBuilder(this, R.style.LogOutStyle)
mDialog.setTitle(resources.getString(R.string.app_name))
mDialog.setMessage(this.resources.getString(R.string.label_app_crash))
mDialog.setPositiveButton(
this.resources.getString(R.string.ok)
) { dialog, _ ->
dialog.dismiss()
}
mDialog.show()
}

interface EnableTrackerInterface {
fun continueToTracker(dialog: DialogInterface)
fun cancel()
Expand Down Expand Up @@ -332,4 +344,4 @@ interface SimulationDialogInterface {
interface NotificationDialogInterface {
fun onOkClick(dialog: DialogInterface)
fun onCancelClick(dialog: DialogInterface)
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values-ar/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,5 @@
<string name="region">المنطقة</string>
<string name="label_enable_open_data">تمكين البيانات المفتوحة</string>
<string name="label_enable_open_data_des">البيانات المفتوحة يستخدم إسري من أجل المسارات و الأماكن بحث وظائف إلى تعزيز ك تجربة.</string>
<string name="label_app_crash">مستحق إلى بعض غير عادي نشاط، ال تطبيق لديه تم إعادة التشغيل.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-de/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,5 @@
<string name="region">Region</string>
<string name="label_enable_open_data">Aktivieren Daten öffnen</string>
<string name="label_enable_open_data_des">Daten öffnen Verwendungszwecke Esri zum Strecken und Orte Suche Funktionalität zu verbessern dein erleben.</string>
<string name="label_app_crash">Fällig zu einige ungewöhnlich Aktivität, die Anwendung hat gewesen neu gestartet.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-es/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,5 @@
<string name="region">Región</string>
<string name="label_enable_open_data">Habilitar Datos abiertos</string>
<string name="label_enable_open_data_des">Datos abiertos usos Esri por Rutas y Lugares búsqueda funcionalidad a mejorar vuestro experiencia.</string>
<string name="label_app_crash">Debido a algunos inusual actividad, la aplicación ha estado reiniciado.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,5 @@
<string name="region">Région</string>
<string name="label_enable_open_data">Activer Données ouvertes</string>
<string name="label_enable_open_data_des">Données ouvertes les usages Esri pour Itinéraires et Lieux chercher fonctionnalité pour améliorer votre expérience.</string>
<string name="label_app_crash">Dû pour quelques inhabituel activité, le candidature a été redémarré.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-hi/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,5 @@
<string name="region">क्षेत्र</string>
<string name="label_enable_open_data">चालू करें ओपनडेटा</string>
<string name="label_enable_open_data_des">ओपनडेटा का उपयोग करता है एसरी के लिए रूट्स और जगहें तलाश कार्यक्षमता को बढ़ाने के लिए तुम्हारा अनुभव।</string>
<string name="label_app_crash">देय को कुछ असामान्य गतिविधि, यह आवेदन पास है गया पुनः आरंभ।</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-it/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,5 @@
<string name="region">Regione</string>
<string name="label_enable_open_data">Abilita Dati aperti</string>
<string name="label_enable_open_data_des">Dati aperti utilizza Esri per Percorsi e Luoghi ricerca funzionalità a accrescere tuo esperienza.</string>
<string name="label_app_crash">Dovuto a alcuni insolito attività, lo candidatura ha stato riavviato.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-iw/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,5 @@
<string name="region">אזור</string>
<string name="label_enable_open_data">הפעל OpenData</string>
<string name="label_enable_open_data_des">OpenData משתמש Esri בשביל מסלולים ו מקומות חפש פונקציונליות כדי לשפר שלך ניסיון.</string>
<string name="label_app_crash">בשל כדי קצת יוצא דופן פעילות, ה יישום יש ל היה הופעל מחדש.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,5 @@
<string name="region">リージョン</string>
<string name="label_enable_open_data">有効化 オープンデータ</string>
<string name="label_enable_open_data_des">オープンデータ 使用する Esri にとって ルート そして 場所 検索 機能性 に 強化します きみの 経験。</string>
<string name="label_app_crash">期限 に 一部 珍しい アクティビティ、 その 応用 持っている されている 再起動しました。</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ko/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,5 @@
<string name="region">지역</string>
<string name="label_enable_open_data">활성화 오픈 데이터</string>
<string name="label_enable_open_data_des">오픈 데이터 사용 에스리 ...에 대한 노선 과 장소 수색 기능성 에 높이다 당신의 경험.</string>
<string name="label_app_crash">기한 에 약간 별난 활동, 그 응용 프로그램 가지고 있습니다 있었다 이 (가) 다시 시작되었습니다.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-pt/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,5 @@
<string name="region">Região</string>
<string name="label_enable_open_data">Habilitar Dados abertos</string>
<string name="label_enable_open_data_des">Dados abertos usa Esri pelo Rotas e Locais procurar funcionalidade para aumentar seu experiência.</string>
<string name="label_app_crash">Devida para alguns incomum atividade, a aplicativo tem fui reiniciado.</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,5 @@
<string name="region">区域</string>
<string name="label_enable_open_data">启用 开放数据</string>
<string name="label_enable_open_data_des">开放数据 使用 Esri 为了 路线 和 地点 搜索 功能 到 提高 您的 经验。</string>
<string name="label_app_crash">到期 到 一些 不寻常 活动, 这 应用程序 有 是 已重新启动。</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,5 @@
<string name="region">地區</string>
<string name="label_enable_open_data">啟用 开放数据</string>
<string name="label_enable_open_data_des">开放数据 使用 埃斯里 為了 路線 和 地方 搜尋 功能 至 提高 你的 經驗。</string>
<string name="label_app_crash">到期 至 一些 不尋常 活動, 該 應用程式 具有 曾經 重新啟動。</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,5 @@
<string name="region">Region</string>
<string name="label_enable_open_data">Enable OpenData</string>
<string name="label_enable_open_data_des">OpenData uses Esri for Routes and Places search functionality to enhance your experience.</string>
<string name="label_app_crash">Due to some unusual activity, the application has been restarted.</string>
</resources>
Loading