我来自 Android 原生背景,最近开始更频繁地使用 Flutter,但我没有任何 ReactNative 经验。
是否可以移植现有的 RN(npm 包)以与 Flutter 应用程序一起使用?我的理解是,符合 RN 的包会公开 JS API。有没有办法实现一种形式的 JS 互操作来实现这一点,或者是不可能的,最好向软件包供应商询问 Android 和 iOS 特定的本机库/SDK 版本(可能用于创建 npm -包最初)?
我最初的看法是这是不可能的,但后来我看到了这篇文章; https://www.thesmythgroup.com/in-development/how-to-use-npm-packages-in-native-ios-apps/
我在将单一任务活动重新放入视图时遇到了一些麻烦.
表现:
<activity
android:name=".test.MyActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:icon="@drawable/my_launcher"
android:label="@string/title_activity_my"
android:launchMode="singleTask"
android:taskAffinity=".myTask"
android:screenOrientation="portrait"
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>
Run Code Online (Sandbox Code Playgroud)
MyActivity代码:
Intent i = new Intent(getApplicationContext(), MyActivity.class);
i.putExtra("blah", stuff);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); // I have tried almost every flag combo here!
startActivity(i);
Run Code Online (Sandbox Code Playgroud)
场景:
在onBackPressed()上,活动调用moveTaskToBack(隐藏我的活动).收到特定的传入事件后,会调用上面的意图代码,但是没有发生!?!没有OnNewIntent()被触发,没有onCreate被激活......
但是:如果我还将一个单独的PendingIntent添加到Notification对象中,它可以工作!?
Intent notificationIntent = new Intent(getApplicationContext(),MyActivity.class);
notificationIntent.putExtra("blah", stuff);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0,
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notif = new Notification(icon,text,when);
notif.flags |= Notification.FLAG_ONGOING_EVENT;
notif.setLatestEventInfo(getApplicationContext(), contentTitle, contentText, contentIntent);
m_notifMgr.notify(1, notif);
Run Code Online (Sandbox Code Playgroud)
我不明白为什么它可以从PendingIntent(触发onNewIntent)工作,但不能直接从startActivity调用.
请指教.谢谢.
更新(1):
我简化了问题并将相同的逻辑放入一个小测试应用程序中:
活动'A'= …