简体   繁体   English

将意图类型添加到 android flutter 清单会导致主屏幕中缺少应用程序图标

[英]Adding intent type to android flutter manifest leads to missing app icon in home screen

I followed the example code mentioned here android intents flutter我按照这里提到的示例代码android 意图 flutter
It worked successfully but it leads to missing the app icon in the Android home screen.它运行成功,但导致 Android 主屏幕中的应用程序图标丢失。
also, I noticed that the app icon depends on the following line in the manifest file.另外,我注意到应用程序图标取决于清单文件中的以下行。

<data android:mimeType="text/plain" />

removing the above line makes the app icon available on the home screen.删除上述行会使应用程序图标在主屏幕上可用。 but android intent functions are not working.但 android 意图功能不起作用。
I can't figure out why is it.我不知道为什么会这样。
Here is a part of manifest file.这是清单文件的一部分。

<application
    android:name="io.flutter.app.FlutterApplication"
    android:label="flutterappjava"
    android:icon="@mipmap/ic_launcher">
    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        .................
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
        </intent-filter>
    </activity>

I found a solution and I hope it's a good solution.我找到了一个解决方案,我希望这是一个好的解决方案。 I separated the action.send intent to a different java file and assigned it to a different activity in the manifest file.我将 action.send 意图分离到不同的 java 文件,并将其分配给清单文件中的不同活动。

<application
android:name="io.flutter.app.FlutterApplication"
android:label="flutterappjava"
android:icon="@mipmap/ic_launcher">
<activity
    android:name=".MainActivity"
    android:launchMode="singleTop"
    android:theme="@style/LaunchTheme"
    .................
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/plain" />
    </intent-filter>
 <activity android:name=".tempAct">
 <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
 </intent-filter>
  </activity>
</activity>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM