Android 应用正在主屏幕中创建重复的快捷方式
Android app is creating duplicated shortcut in homescreen
我 运行 模拟器(和手机)上的应用程序,它在主屏幕上创建了 2 个快捷方式。如果我删除应用程序,它会删除两个快捷方式。
我的应用在 splash screen
上,然后转到主屏幕,我正在使用 android studio。
我认为与 <intent-filter>
有关,但每次我删除 运行 应用程序时,它都会再次自动出现在两个 <activity>
上。
清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.epicbit.tecnoprolab"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="23" />
<receiver android:name="receiver.NetworkChangeReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<!-- Splash screen -->
<activity
android:name="com.example.epicbit.tecnoprolab.SplashScreen"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.epicbit.tecnoprolab.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
编辑:
观看此视频以了解当我遵循您的建议时会发生什么:
从 MainActivity
中删除以下代码
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
您的 SplashScreen 将成为您应用程序的根 Activity...因此,仅 SplashScreen 需要这些参数。
最终结果
<!-- Splash screen -->
<activity
android:name="com.example.epicbit.tecnoprolab.SplashScreen"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.epicbit.tecnoprolab.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" >
</activity>
更新
我查看了你的照片。
我看到您正在更新以下文件:
app/build/intermediates/manifests/full/debug/AndroidManifest.xml
但是,app/build文件是一个文件夹,AndroidStudio把生成的文件...
尝试在您的源代码文件夹中搜索清单。类似于:
app/src/... (or any other folder different from build)
您的清单应该是一个 MAIN 操作以及一个启动 activity 用于您的应用程序
的 LAUNCHER intent-filter
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
仅适用于您的应用程序的根 activity。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.epicbit.tecnoprolab"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="23" />
<receiver android:name="receiver.NetworkChangeReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<!-- Splash screen -->
<activity
android:name="com.example.epicbit.tecnoprolab.SplashScreen"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.epicbit.tecnoprolab.MainActivity"
android:label="@string/app_name" >
</activity>
</application>
就我而言,应用升级后创建了重复的图标。在此升级中,我们引入了启动画面。这是因为我们已经重命名了启动器 activity。我们移动了
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
从 MainActivity 到初始屏幕 activity。
在某些 phone 中,重命名 activity 会创建重复的图标。
奇怪。重命名活动在这里有所帮助。
可在 OnePlus One 中重现 phone。
我 运行 模拟器(和手机)上的应用程序,它在主屏幕上创建了 2 个快捷方式。如果我删除应用程序,它会删除两个快捷方式。
我的应用在 splash screen
上,然后转到主屏幕,我正在使用 android studio。
我认为与 <intent-filter>
有关,但每次我删除 运行 应用程序时,它都会再次自动出现在两个 <activity>
上。
清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.epicbit.tecnoprolab"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="23" />
<receiver android:name="receiver.NetworkChangeReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<!-- Splash screen -->
<activity
android:name="com.example.epicbit.tecnoprolab.SplashScreen"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.epicbit.tecnoprolab.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
编辑: 观看此视频以了解当我遵循您的建议时会发生什么:
从 MainActivity
中删除以下代码<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
您的 SplashScreen 将成为您应用程序的根 Activity...因此,仅 SplashScreen 需要这些参数。
最终结果
<!-- Splash screen -->
<activity
android:name="com.example.epicbit.tecnoprolab.SplashScreen"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.epicbit.tecnoprolab.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" >
</activity>
更新
我查看了你的照片。
我看到您正在更新以下文件:
app/build/intermediates/manifests/full/debug/AndroidManifest.xml
但是,app/build文件是一个文件夹,AndroidStudio把生成的文件...
尝试在您的源代码文件夹中搜索清单。类似于:
app/src/... (or any other folder different from build)
您的清单应该是一个 MAIN 操作以及一个启动 activity 用于您的应用程序
的 LAUNCHER intent-filter<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
仅适用于您的应用程序的根 activity。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.epicbit.tecnoprolab"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="23" />
<receiver android:name="receiver.NetworkChangeReceiver" >
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<!-- Splash screen -->
<activity
android:name="com.example.epicbit.tecnoprolab.SplashScreen"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.epicbit.tecnoprolab.MainActivity"
android:label="@string/app_name" >
</activity>
</application>
就我而言,应用升级后创建了重复的图标。在此升级中,我们引入了启动画面。这是因为我们已经重命名了启动器 activity。我们移动了
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
从 MainActivity 到初始屏幕 activity。
在某些 phone 中,重命名 activity 会创建重复的图标。 奇怪。重命名活动在这里有所帮助。
可在 OnePlus One 中重现 phone。