首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当app处于前台时,接受adb的Android意图

当app处于前台时,接受adb的Android意图
EN

Stack Overflow用户
提问于 2022-07-28 00:27:25
回答 1查看 295关注 0票数 0

我在前台运行我的应用程序,当我在下面发出亚行命令时,我会收到警告信息。它说意图已经实现,但我不知道如何在我的MainActivity中接收它。如果能在这个问题上提供任何帮助,我们将不胜感激。

代码语言:javascript
运行
复制
adb shell am start -a com.ilw.admin.INSTALL_COMPLETE

Starting: Intent { act=com.ilw.admin.INSTALL_COMPLETE }
Warning: Activity not started, intent has been delivered to currently running top-most instance.

AndroidManifest.xml活性

代码语言:javascript
运行
复制
       <activity
            android:name=".MainActivity"
            android:exported="true"
            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">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <action android:name="com.ilw_admin.INSTALL_COMPLETE"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-28 06:12:00

活动是清单中提到的SingleTop。因此,如果活动已经在堆栈的顶部,并且活动再次启动,那么将调用onNewIntent,并在这里传递意图。

代码语言:javascript
运行
复制
override fun onNewIntent(intent: Intent?) {
    super.onNewIntent(intent)
   
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73145944

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档