我正在编写适用于Wear OS的应用程序。在手表上启动应用程序时,应用程序也必须立即在手机上启动。手表上的启动命令成功到达,但手机上的应用程序未启动。使用意图过滤器尝试启动:
if (messageEvent?.path.equals(START_ACTIVITY_ON_PHONE_PATH)) {
val startIntent = Intent("com.example.app.gui.activities.SplashActivity")
startIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(startIntent)
}
在清单中:
<activity
android:name="com.example.app.gui.activities.SplashActivity"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.SplashActivity"
android:windowSoftInputMode="stateHidden|stateAlwaysHidden">
<intent-filter>
<action android:name="com.example.app.gui.activities.SplashActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
也尝试使用显式调用SplashActivity:
if (messageEvent?.path.equals(START_ACTIVITY_ON_PHONE_PATH)) {
val startIntent = Intent(this,SplashActivity::class.java)
startIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(startIntent)
}
具有路径的部分正在工作,并且始终在日志中显示:
I/Timeline: Timeline: Activity_launch_request time:3649351