Last active
June 14, 2023 09:18
-
-
Save nisaefendioglu/c2f0724a7fcce869702a34c98da9d68f to your computer and use it in GitHub Desktop.
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
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.nisaefendioglu.example"> | |
<application> | |
<activity | |
android:name=".MainActivity" | |
android:exported="true"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
</intent-filter> | |
</activity> | |
<activity-alias | |
android:name=".FirstAppIcon" | |
android:enabled="true" | |
android:exported="true" | |
android:icon="@mipmap/first" | |
android:label="@string/app_name" | |
android:roundIcon="@mipmap/first" | |
android:targetActivity=".MainActivity"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity-alias> | |
<activity-alias | |
android:name=".SecondAppIcon" | |
android:enabled="false" | |
android:exported="true" | |
android:icon="@mipmap/second" | |
android:label="@string/app_name" | |
android:roundIcon="@mipmap/second" | |
android:targetActivity=".MainActivity"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity-alias> | |
<activity-alias | |
android:name=".ThirdAppIcon" | |
android:enabled="false" | |
android:roundIcon="@mipmap/third" | |
android:exported="true" | |
android:icon="@mipmap/third" | |
android:label="@string/app_name" | |
android:targetActivity=".MainActivity"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity-alias> | |
</application> | |
</manifest> |
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
package com.nisaefendioglu.example | |
import android.content.ComponentName | |
import android.content.pm.PackageManager | |
import android.os.Bundle | |
import android.view.View | |
import androidx.appcompat.app.AppCompatActivity | |
import com.nisaefendioglu.example.databinding.ActivityMainBinding | |
class MainActivity : AppCompatActivity() { | |
private lateinit var binding: ActivityMainBinding | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
binding = ActivityMainBinding.inflate(layoutInflater) | |
setContentView(binding.root) | |
initialize() | |
handleClickEvents() | |
} | |
private fun handleClickEvents() { | |
binding.btnFirst.setOnClickListener { | |
setIcon(ICON_NUMBER.FirstAppIcon) | |
} | |
binding.btnSecond.setOnClickListener { | |
setIcon(ICON_NUMBER.SecondAppIcon) | |
} | |
binding.btnThird.setOnClickListener { | |
setIcon(ICON_NUMBER.ThirdAppIcon) | |
} | |
} | |
private fun setIcon(targetNumber: ICON_NUMBER) { | |
for (number in ICON_NUMBER.values()) { | |
val action = if (number == targetNumber) { | |
PackageManager.COMPONENT_ENABLED_STATE_ENABLED | |
} else { | |
PackageManager.COMPONENT_ENABLED_STATE_DISABLED | |
} | |
val componentName = ComponentName(packageName, "${packageName}.${number.name}") | |
packageManager.setComponentEnabledSetting(componentName, action, PackageManager.DONT_KILL_APP) | |
} | |
} | |
private fun initialize() { | |
binding = ActivityMainBinding.bind(findViewById<View>(android.R.id.content)) | |
} | |
enum class ICON_NUMBER { FirstAppIcon, SecondAppIcon, ThirdAppIcon } | |
} |
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
{ | |
"birthdayIconEnabled": true, | |
"birthdayIconPath": "birthday_icon.png" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment