从Google Play下载的Xamarin android应用在主屏幕中提供了两个应用图标

时间:2018-07-09 09:09:31

标签: android xamarin xamarin.forms google-play

我已经开发了xamarin表单应用程序,并将apk文件上传到Google Play。现在我的问题是,当我下载我的应用程序时,它在手机中设置了两个图标。

我添加了manifest.xml代码和mainactivity.cs代码

       namespace SigaramDictionary.Droid
       {
         [Activity(Label = "Sigaram Dictionary", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
      public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
      {
        protected override void OnCreate(Bundle bundle)
       {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate(bundle);

        global::Xamarin.Forms.Forms.Init(this, bundle);


        LoadApplication(new App());
        }

       }
    }

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.wordsmith.SigaramDictionary" android:installLocation="internalOnly">
  <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="27" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <application android:name="android.app.Application" android:allowBackup="true" android:label="com.wordsmith.SigaramDictionary" android:icon="@drawable/icon">
    <activity android:configChanges="orientation|screenSize" android:icon="@drawable/icon" android:label="Sigaram Dictionary" android:theme="@style/MainTheme" android:name="md59e0757bc4d49a795ebfdd671adca454e.MainActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <receiver android:enabled="true" android:label="Connectivity Plugin Broadcast Receiver" android:name="md59628c2715c1bb8febcc7ae8402df0582.ConnectivityChangeBroadcastReceiver" />
    <activity android:name="md5ffa21440d43fa9f7b0ce3fc2ebd14867.MediaPickerActivity" />
    <provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="com.wordsmith.SigaramDictionary.mono.MonoRuntimeProvider.__mono_init__" />
  </application>
</manifest>

如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

通过在[Activity]上方指定MainActivity属性,然后在您的Manifest.xaml中,您将有两个Activities作为MainLauncher,这将导致两个图标。调试时也应该发生这种情况。

您可能可以从MainLauncher = true上方的[Activity]属性中删除MainActivity