-
Notifications
You must be signed in to change notification settings - Fork 50
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
Android support #10
base: master
Are you sure you want to change the base?
Android support #10
Conversation
@tastelessjolt I made the Android support, take a look. |
I also refactored the example app to make more easy to read |
IconChanger.enableIcon(context, iconName); | ||
IconChanger.disableIcon(context, "MainActivity"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, thanks for the contribution.
This makes only one alternative icon available.
I think we should disable all possible other icons and enable the selected icon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, how do you think it should restore to the default icon?
The API used for restoring icon in iOS is that, passing null
to setAlternateIcon(?) should restore the icon to the main/primary icon. I would like to keep the same API for Android as well.
I haven't tested the app as I don't have a PC currently.
PackageInfo info = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES | PackageManager.GET_DISABLED_COMPONENTS); | ||
ActivityInfo enabled = null; | ||
for(ActivityInfo activityInfo: info.activities) { | ||
// An hard coded way to get only the app activities, only way I found :( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://developer.android.com/reference/android/content/pm/ActivityInfo#targetActivity
Check this attribute, you can check targetActivity
for null
to know whether it is a activity-alias
or not. And for the main activity, I don't quite know, you might find something for the MainActivity
.
} else if (call.method.equals("mSetAlternateIconName")) { | ||
result.error("Not supported", "Not supported on Android", null); | ||
String iconName = call.argument("iconName"); | ||
if(iconName == null) iconName = "MainActivity"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MainActivity is not the default value. It is better to use getActivities first element of the array
@GioPan04 any update on this? |
We're looking forward to this feature as well! Any news? |
Any updates on this PR? |
Sorry for the long absence |
I have same issue, I'm investigating on |
This the issue that I encountered:
Following native guide to set |
@giandifra have you found the solution for the problem? Thanks! |
I didn't |
Any hope for this? 🥲 |
As long as this issue exists upstream, flutter/flutter#38965, android support won't be published It's a bad user experience that you have to crash the app to change the app icon. |
I don't think it's possible without stopping the app, but we can restart, see this commit. |
The app will be stopped when you change the icon dynamically from app, it happens in Android Native as well. |
@tastelessjolt you can try integrating this alternative solution on activity-alias Screen.Recording.2023-02-08.at.21.41.10.mov |
by using this package I am able to change the app launcher icon and able to set it to default, but after setting it to default I open the app then my app is not opening and instead of that app info page is opening |
Have you all check other plugin flutter_dynamic_icon_plus? |
This package only supports iOS not android. |
Android support for the plugin (except batch numbers, that are not available on Android). Fixes #9