保持基本应用在使用 Android AAB 时发生功能崩溃时保持运行。

huangapple go评论54阅读模式
英文:

Keep base app alive when feature crash, when using android aab

问题

我为物联网开发了一个Android应用程序,该应用程序是系统中唯一的应用程序。为了动态更新它,我使用aab构建它。我将基础应用视为'桌面',将动态功能视为'系统中的其他应用程序'。为了获得最佳体验,'桌面'必须始终保持活动状态。

所以问题是,当动态功能崩溃时,如何保持基础应用程序的活动?

我希望达到的最佳效果是,在动态功能崩溃时,无需重新启动,返回到基础应用程序,就像系统中的应用程序崩溃后返回到桌面一样。

英文:

I develop an Android app for Iot, and the App is the only one in system. To update it dynamically I build it with aab. I regard the base app as 'desktop' and dynamic features as 'other apps in system'. To get the best experence, the 'desktop', has to be alive always.

So the question is, How to keep base app alive when crash happened in dynamic feathres?

The best effect I hope is, without restarting, return to the base app, when crash happened in dynamic feathres. It just like the effect in system: apps crashed and go back to desktop.

答案1

得分: 2

The base and feature modules all run in the same process as if they lived in a single APK, so don't search something specific to dynamic delivery to solve your problem, you'll have to use regular coding patterns to catch exceptions at the right places when invoki

英文:

The base and feature modules all run in the same process as if they lived in a single APK, so don't search something specific to dynamic delivery to solve your problem, you'll have to use regular coding patterns to catch exceptions at the right places when invoki

答案2

得分: 1

只有一种方法。构建多进程应用程序。
在清单中定义要使用的不同进程<a href="https://developer.android.com/guide/topics/manifest/application-element#proc">android:process</a>。

应用程序的所有组件应该运行的进程名称。每个组件可以通过设置自己的进程属性来覆盖此默认值。
默认情况下,当应用程序的第一个组件需要运行时,Android会为应用程序创建一个进程。然后所有组件都在该进程中运行。默认进程的名称与<manifest>元素设置的包名称匹配。
通过将此属性设置为与另一个应用程序共享的进程名称,您可以安排两个应用程序的组件在同一进程中运行,但前提是这两个应用程序还共享用户ID并使用相同的证书签名。

您可以在应用程序和组件(广播接收器、服务、活动、内容提供程序)级别定义进程。
但是,请记住,由于您的特性和基础应用程序在不同的进程中运行,因此您应该使用IPC来相互通信。
此外,静态全局字段和lock对此没有用。

英文:

There is only one way. Build Multi-process application.
Define distinct process to use in your manifest
<a href="https://developer.android.com/guide/topics/manifest/application-element#proc">android:process</a>.

> The name of a process where all components of the application should run. Each component can override this default by setting its own process attribute.
By default, Android creates a process for an application when the first of its components needs to run. All components then run in that process. The name of the default process matches the package name set by the <manifest> element.
By setting this attribute to a process name that's shared with another application, you can arrange for components of both applications to run in the same process — but only if the two applications also share a user ID and are signed with the same certificate.

You can define the process at Application and Component(BroadCastReceiver, Service,Activity, ContentProvider) Level.
But, remember since your feature and base app runs in separate process. so you should IPC to communicate to each other.
Also, static global field and lock is no use for this.

huangapple
  • 本文由 发表于 2023年4月6日 23:47:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75951417.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定