-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat[firebase]: Firebase 초기화 시 멀티프로세스 이슈 수정
- Loading branch information
Showing
2 changed files
with
26 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/hmh/hamyeonham/firebase/FirebaseUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.hmh.hamyeonham.firebase | ||
|
||
import android.app.ActivityManager | ||
import android.app.Application | ||
import android.content.Context | ||
import com.google.firebase.crashlytics.FirebaseCrashlytics | ||
|
||
fun Application.setFirebaseCrashlyticsEnabled(isEnabled: Boolean) { | ||
|
||
fun getProcessName(): String? { | ||
val activityManager = | ||
applicationContext.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager | ||
val pid = android.os.Process.myPid() | ||
return activityManager.runningAppProcesses?.firstOrNull { it.pid == pid }?.processName | ||
} | ||
|
||
fun isMainProcess(): Boolean { | ||
return getProcessName() == applicationContext.packageName | ||
} | ||
|
||
if (isMainProcess()) { | ||
FirebaseCrashlytics.getInstance().isCrashlyticsCollectionEnabled = isEnabled | ||
} | ||
} |