android - 默认的android :sharedUserId set if android:sharedUserId was not set是什么

标签 android android-manifest

来自documentation :

The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID.

假设我有一个未在 AndroidManifest.xml 文件中指定 android:sharedUserId 的应用。

Android 生成的默认 sharedUserId 是否在构建中设置(此应用在所有设备上都相同),还是在安装该应用的每台设备上生成不同的 sharedUserId?

最佳答案

Android 为您在设备上安装的每个应用程序生成随机唯一 ID。

您可以通过以下方式获取此值:

adb shell dumpsys package com.example.myapp | grep userId=

或在代码中:

int uId = getPackageManager().getApplicationInfo("com.example.myapp",PackageManager.GET_META_DATA).uid;

但是,如果您为两个或多个应用设置相同的 android:sharedUserId 值,它们将共享相同的 ID — 前提是它们的证书集相同。

具有相同用户 ID 的应用可以访问彼此的数据,如果需要,还可以在同一进程中运行。

关于android - 默认的android :sharedUserId set if android:sharedUserId was not set是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43688681/

相关文章:

android - 在 fontfamily 回退调用中加载所有字体系列

Android 电子市场/Google Play 网址

android - 如何从 "Date"对象中获取本地化的 TIME 作为字符串?

Android 'debuggable' 默认值

android - 语言环境:未调用 onConfigurationChanged

Android 蓝牙 : java. io.IOException: 服务发现失败

java - 在 Android Studio 中创建可变 ArrayList 以保存输入文本

android - 继承安卓主题

android - 手机启动时服务没有启动

Android GPS 打开或关闭状态