2016-07-11 171 views
0

我在模拟器(和手机上)上运行应用程序,并且它在主屏幕中创建2个快捷方式。如果我删除该应用程序,它将删除这两个快捷方式。Android应用程序在主屏幕上创建重复的快捷方式

我的应用程序有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> 

编辑: 检查此视频,了解当我按照你的sugestions发生什么:

https://vid.me/onhe

回答

0

移除MainActivity

下面的代码
<intent-filter> 
    <action android:name="android.intent.action.MAIN" /> 

    <category android:name="android.intent.category.LAUNCHER" /> 
</intent-filter> 

您的SplashScreen将成为您的应用程序的根本活动...因此,这些参数仅适用于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> 

UPDATE

我检查你的照片。

我看到你正在更新以下文件:

app/build/intermediates/manifests/full/debug/AndroidManifest.xml 

然而,应用程序/构建文件是一个文件夹中的Android工作室把生成的文件...

尝试搜索清单中你的源代码文件夹..喜欢的东西:

app/src/... (or any other folder different from build) 
+0

不工作。当我在android studio上运行时。自动他再次添加: ' ' 我的mainActivity。我不明白为什么。 –

+0

@CarlosBranco您是否在应用程序中添加了一些库?或类似的东西?也许,Android Studio正在合并清单文件与另一个... – W0rmH0le

+0

我的项目是非常小的。 http://i.imgur.com/2Lo80Yl.png 选中此项。嗯,我不明白为什么会发生这种情况。 –

0

你的表现应该是一个主要的行动并为您的应用程序了启动活动也是一个LAUNCHER意图过滤器

<intent-filter> 
    <action android:name="android.intent.action.MAIN" /> 
    <category android:name="android.intent.category.LAUNCHER" /> 
</intent-filter> 

仅用于应用程序的根活动。

<?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> 
+0

不工作。每当我运行应用程序时,我的Android工作室都会将添加到所有活动中。 –

相关问题