Skip to content

Commit

Permalink
Exclude own package from map app installed check
Browse files Browse the repository at this point in the history
  • Loading branch information
tapetis authored and westnordost committed Sep 24, 2023
1 parent 85e4e92 commit f48e11b
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.content.res.Configuration
import android.graphics.PointF
import android.graphics.Rect
Expand Down Expand Up @@ -809,7 +810,9 @@ class MainFragment :
val uri = buildGeoUri(pos.latitude, pos.longitude, zoom)

val intent = Intent(Intent.ACTION_VIEW, uri)
if (intent.resolveActivity(ctx.packageManager) != null) {
val otherMapAppInstalled = ctx.packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)
.any { !it.activityInfo.packageName.equals(ctx.packageName) }
if (otherMapAppInstalled) {
startActivity(intent)
} else {
ctx.toast(R.string.map_application_missing, Toast.LENGTH_LONG)
Expand Down

0 comments on commit f48e11b

Please sign in to comment.