+
Skip to content

Conversation

Goooler
Copy link

@Goooler Goooler commented Aug 31, 2024

Proposed Changes

androidx.core.graphics.drawable.IconCompat.toIcon() is deprecated, we should avoid calling it in core lib to prevent the exception thrown like:

java.lang.IllegalArgumentException: Context is required to resolve the file uri of the icon: content://com.google.android.samples.socialite/icon/1
    at androidx.core.graphics.drawable.IconCompat$Api23Impl.toIcon(IconCompat.java:1297)
    at androidx.core.graphics.drawable.IconCompat.toIcon(IconCompat.java:529)
    at androidx.core.graphics.drawable.IconCompat.toIcon(IconCompat.java:517)
    at androidx.core.app.Person$Api28Impl.toAndroidPerson(Person.java:427)
    at androidx.core.app.Person.toAndroidPerson(Person.java:152)
    at androidx.core.app.NotificationCompatBuilder.<init>(NotificationCompatBuilder.java:263)
    at androidx.core.app.NotificationCompat$Builder.build(NotificationCompat.java:2531)
    at com.google.android.samples.socialite.repository.NotificationHelper.showNotification(NotificationHelper.kt:274)
    at com.google.android.samples.socialite.repository.NotificationHelper.showNotification$default(NotificationHelper.kt:159)
    at com.google.android.samples.socialite.repository.ChatRepository$sendMessage$2.invokeSuspend(ChatRepository.kt:92)

Testing

./gradlew :core:core:check

Issues Fixed

This will fix the issue reported at android/socialite#41, you can see more details and context there.

@Goooler Goooler requested a review from alanv as a code owner August 31, 2024 06:49
`androidx.core.graphics.drawable.IconCompat.toIcon()` is deprecated, we should avoid calling it in core lib to prevent the exception thrown like:

```
java.lang.IllegalArgumentException: Context is required to resolve the file uri of the icon: content://com.google.android.samples.socialite/icon/1
    at androidx.core.graphics.drawable.IconCompat$Api23Impl.toIcon(IconCompat.java:1297)
    at androidx.core.graphics.drawable.IconCompat.toIcon(IconCompat.java:529)
    at androidx.core.graphics.drawable.IconCompat.toIcon(IconCompat.java:517)
    at androidx.core.app.Person$Api28Impl.toAndroidPerson(Person.java:427)
    at androidx.core.app.Person.toAndroidPerson(Person.java:152)
    at androidx.core.app.NotificationCompatBuilder.<init>(NotificationCompatBuilder.java:263)
    at androidx.core.app.NotificationCompat$Builder.build(NotificationCompat.java:2531)
    at com.google.android.samples.socialite.repository.NotificationHelper.showNotification(NotificationHelper.kt:274)
    at com.google.android.samples.socialite.repository.NotificationHelper.showNotification$default(NotificationHelper.kt:159)
    at com.google.android.samples.socialite.repository.ChatRepository$sendMessage$2.invokeSuspend(ChatRepository.kt:92)
```

Test: ./gradlew :core:core:check
Change-Id: I9c3874ae91efbb382693f679cadad62a9cba4a83
@Goooler Goooler force-pushed the fix-icon-compat-to-icon branch from 62d768f to d3a2031 Compare August 31, 2024 06:50
@Goooler Goooler changed the title Pass context for IconCompat.toIcon Pass context for calling IconCompat.toIcon Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载