android:exported =true,什么是具有相同用户ID的Android应用程序

在这里插入图片描述在这里插入图片描述
android:exported 是Android中的四大组件 Activity,Service,Provider,Receiver 四大组件中都会有的一个属性。

总体来说它的主要作用是:是否支持其它应用调用当前组件。
默认值:如果包含有intent-filter 默认值为true; 没有intent-filter默认值为false。

在Activity中该属性用来标示:当前Activity是否可以被另一个Application的组件启动:true允许被启动;false不允许被启动。

如果被设置为了false,那么这个Activity将只会被当前Application或者拥有同样user ID的Application的组件调用。

exported 的默认值根据Activity中是否有intent filter 来定。没有任何的filter意味着这个Activity只有在详细的描述了他的class name后才能被唤醒 .这意味着这个Activity只能在应用内部使用,因为其它application并不知道这个class的存在。所以在这种情况下,它的默认值是false。从另一方面讲,如果Activity里面至少有一个filter的话,意味着这个Activity可以被其它应用从外部唤起,这个时候它的默认值是true。

其实,不只有这个属性可以指定Activity是否暴露给其它应用,也可以使用permission来限制外部实体唤醒当前Activity(详情见permission属性)

两个具有相同用户ID的Android应用程序

从http://developer.android.com/guide/topics/fundamentals.html:

It’s possible to arrange for two applications to share the same Linux
user ID, in which case they are able to access each other’s files. To
conserve system resources, applications with the same user ID can also
arrange to run in the same Linux process and share the same VM (the
applications must also be signed with the same certificate).

如何为两个应用程序实现相同的用户ID
您可以通过将AndroidManifest.xml文件中的sharedUserLabel和sharedUserId设置为相同的值来实现此目的.例如,如果我有以下2个清单文件(我只包括开始):

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      android:sharedUserLabel="@string/label_shared_user" 
      android:sharedUserId="com.example" 
      package="com.example.package1" 
      android:versionName="2.0.0" 
      android:versionCode="2">

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      android:sharedUserLabel="@string/label_shared_user"
       android:sharedUserId="com.example"
        package="com.example.package2" 
        ndroid:versionName="1.0.0" 
        android:versionCode="1">

那么他们将共享同一个用户资源.

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值