阅读笔记1

来源:互联网 发布:windows窗口样式 编辑:程序博客网 时间:2024/05/20 11:32

1:每个android app相当于一个linux用户,拥有自己独一无二的user id,每个进程都有自己独立的VM(虚拟机,每个app有一个或者多个进程组成),所以每个APP都能独立运行

2:每个android 厂商的设备必须通过CTS的测试

3.If necessary, you can prevent users from installing your app when their devices don't provide a given feature by declaring it with a <uses-feature> element in your app's manifest file.(如果有必要的话,当用户的设备不提供你在manifest 文件里声明的uses-feature元素时,那么该用户将不能安装你的app)

4. you can query whether a feature is available by calling hasSystemFeature() like this:

PackageManager pm = getPackageManager();if (!pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_COMPASS)) {    // This device does not have a compass, turn off the compass feature    disableCompassFeature();}
你可以查询某个功能是否可用。
5.You can use the sharedUserId attribute in the AndroidManifest.xml's manifest tag of each package to have them assigned the same user ID. (可以通过在xml里设置sharedUserId来保证每个包都有同样的user id,相同的user id 会运行在同一个进程下,数据共享)
6。

Often times a permission failure will result in a SecurityException being thrown back to the application. However, this is not guaranteed to occur everywhere. For example, the sendBroadcast(Intent) method checks permissions as data is being delivered to each receiver, after the method call has returned, so you will not receive an exception if there are permission failures. In almost all cases, however, a permission failure will be printed to the system log.(通常情况下,权限错误将会导致SecurityException,但是不保证在任何地方都发生,比如发送广播的时候。尽管如此,权限错误将会打印出log)

7.

<permission android:name="com.me.app.myapp.permission.DEADLY_ACTIVITY"        android:label="@string/permlab_deadlyActivity"        android:description="@string/permdesc_deadlyActivity"        android:permissionGroup="android.permission-group.COST_MONEY"        android:protectionLevel="dangerous" />

The <protectionLevel> attribute is required, telling the system how the user is to be informed of applications requiring the permission, or who is allowed to hold that permission, as described in the linked documentation.

The <permissionGroup> attribute is optional, and only used to help the system display permissions to the user. You will usually want to set this to either a standard system group (listed inandroid.Manifest.permission_group) or in more rare cases to one defined by yourself. It is preferred to use an existing group, as this simplifies the permission UI shown to the user.(level是必须的,通知系统,用户是怎么样被告知需要哪些权限的,或者谁被允许持有这些权限,group是可选的,仅仅用户帮助系统显示权限给用户)

8.

To show the chooser, create an Intent using createChooser() and pass it to startActivity(). For example:

Intent sendIntent = new Intent(Intent.ACTION_SEND);...// Always use string resources for UI text.// This says something like "Share this photo with"String title = getResources().getString(R.string.chooser_title);// Create intent to show the chooser dialogIntent chooser = Intent.createChooser(sendIntent, title);// Verify the original intent will resolve to at least one activityif (sendIntent.resolveActivity(getPackageManager()) != null) {    startActivity(chooser);}

This displays a dialog with a list of apps that respond to the intent passed to the createChooser() method and uses the supplied text as the dialog title.

当你的隐式意图有多个app与之对应时,用户能够选择具体哪一个app来响应该意图,可以通过createChooser方法来显示选择的title,app顺序由系统决定,不可控。




0 0
原创粉丝点击