This Android project demonstrates a method to dynamically change app icons at runtime, providing users with a more personalized experience. The solution involves utilizing activity-alias in the app's manifest file and leveraging the PackageManager class to switch between different icons seamlessly.
The core implementation revolves around using activity-alias in the manifest file to define alternate activities with distinct icons. The key steps include:
-
Manifest Setup: Define the main activity and an activity alias with different icons.
-
PackageManager Usage: Utilize the PackageManager class to enable/disable activity aliases, effectively changing the app's icon at runtime.
-
Code Refactoring: Enhance code cleanliness by abstracting component names and leveraging BuildConfig and manifest placeholders for flexibility.
- MainActivity: Contains the core logic to switch between activity-aliases for icon changes.
- Utility Functions: The
changeEnabledComponent
function provides a clean way to toggle activity-aliases.
- Manifest File: Demonstrates the use of activity-alias and manifest placeholders.
- Build.gradle: Utilizes BuildConfig and manifest placeholders for dynamic component names.
- The project contains a sample user interface to demonstrate the icon change functionality interactively.
- Clone or download the project.
- Import it into Android Studio or your preferred IDE.
- Run the app on an Android device or emulator.
- Click designated UI elements to trigger icon changes using the implemented method.
Contributions to enhance the project or extend its functionality are welcome! Feel free to fork this repository, make changes, and create pull requests.