问题描述
我刚刚使用Flutter框架开发了一个电子商务应用程序,我试图共享任何产品的特定URL,以便客户可以使用共享URL在应用程序中打开此产品详细信息屏幕。 我已经使用uni_links包来处理此链接,但是我不知道出了什么问题,因为当我在浏览器中打开URL时应用程序无法打开,这是我使用的代码。 / p>
1- AndroidManifest.xml
<application
android:name="io.Flutter.app.FlutterApplication"
android:label="ecards"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singletop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<Meta-data
android:name="io.Flutter.embedding.android.normalTheme"
android:resource="@style/normalTheme"
/>
<Meta-data
android:name="io.Flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.broWSABLE" />
<data
android:scheme="unilinks"
android:host="example.com" />
</intent-filter>
</activity>
<!-- Don't delete the Meta-data below.
This is used by the Flutter tool to generate GeneratedpluginRegistrant.java -->
<Meta-data
android:name="FlutterEmbedding"
android:value="2" />
</application>
2-用于处理URL的uni_links代码
导入'dart:async'; 导入'package:uni_links / uni_links.dart';
StreamSubscription _sub;
Future<Null> initUniLinks() async {
_sub = getLinksstream().listen((String link) {
print(link);
},onError: (err) {
print(err);
});
}
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await initUniLinks();
await translator.init(
localeDefault: LocalizationDefaultType.device,languagesList: <String>['ar','en'],assetsDirectory: 'assets/langs/',);
注意:我正在使用小米mi 9t来测试应用程序
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)