In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
The main content of this article is to explain "Android how to achieve app local switch between logo and name", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Android how to achieve app local switch between logo and name" bar!
First of all, in the AndroidManifest.xml file of app, configure the logo and app names to be replaced
Eg: the following is configured with a default set of two sets of icon and names for switching
Android:enabled: when set to "true", the Activity of the current alias is enabled, and the current icon and the current application name are enabled: when set to "false", the Activity of the current alias is stopped
Android:icon: the application icon for the current alias
Android:label: the application name of the current alias
Android:name: alias. Naming rules are the same as Actively.
Android:targetActivity: the name of the actual Activity called by alias
Then there is code switching: an introduction to related methods.
Toggle the enable / stop state on any component defined in the manifest file through PackageManager.
PackageManager.setComponentEnabledSetting
Sets the enabling settings for package components (activities, receivers, services, providers). This setting overrides any enabled state set by the component in its inventory.
Parameters:
Components to be enabled by componentName-
The newly enabled state of the newState- component.
Optional behavior flags for flags-
Package com.cgg.change_iconimport android.content.ComponentNameimport android.content.Contextimport android.content.pm.PackageManagerimport androidx.appcompat.app.AppCompatActivityimport android.os.Bundleimport android.widget.Buttonimport android.widget.ImageViewimport android.widget.RadioGroupimport androidx.annotation.StringDefclass MainActivity: AppCompatActivity () {val APP_D = "com.cgg.change_icon.DefaultAliasActivity" val APP_1 = "com.cgg.change_icon.Alias1Activity" val APP_2 = "com.cgg.change_icon.Alias2Activity" Private var mPackageManager: PackageManager? = null override fun onCreate (savedInstanceState: Bundle?) {super.onCreate (savedInstanceState) setContentView (R.layout.activity_main) mPackageManager = applicationContext.packageManager findViewById (R.id.iv_0). SetOnClickListener {ShowComponent (APP_D)} findViewById (R.id.iv_1). SetOnClickListener {ShowComponent (APP_1)} FindViewById (R.id.iv_2). SetOnClickListener {ShowComponent (APP_2)}} private fun ShowComponent (app: String) {packageManager.run {setComponentEnabledSetting (componentName) PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP) setComponentEnabledSetting (ComponentName (baseContext, app), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP)}
Paste the layout, too.
Now that the function is over, let's talk about the defects.
When the replacement icon needs to be packaged, it is pre-embedded in the code. After icon switch is the same as the flicker, if you update the package without activity-alias, it will cause the risk that APP will never find it from the desktop again.
At this point, I believe you have a deeper understanding of "Android how to achieve app local switching between logo and names". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.