android studio for android learning (二)

来源:互联网 发布:相片日期修改软件 编辑:程序博客网 时间:2024/06/14 13:10

1.为什么要考虑设备的兼容性?

android可以用在不同的设备上,如手机,手表,电视等,不同的设备有不同的尺寸,需要我们去适用。你可以用一个静态的xml文件来设置设备的配置,这样你就可以用一个APK来通过android来配置不同的尺寸,用来支持不同的平台。

2. 兼容性包括两类,1是设备兼容,2是软件兼容(APP)。

3. 你写的APP要放到google play store上必需要满足下面几点

1. Device features

2. Platform version

3. Screen configuration

例如:你的APP需要的compass,如果没有,google play store 将会阻止它的安装。

<manifest ... >    <uses-feature android:name="android.hardware.sensor.compass"                  android:required="true" />    ...</manifest>

4. 平台兼容性,这里是指google平台,如果android4.0 和android4.4 不同的平台有不同的API,新的平台中的API可能是旧版本中没有的,所以,在平台兼容性上可以设置最低兼容平台,其中android1.0的API level=1,而android 4.4 is api level 14,minSdkVersion是指最小的兼容等级,targetSdkVersion指你会优化支持的等级。

<manifest ... >    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />    ...</manifest>

5.系统权限(权限许可组和相应权限)

Permission Group Permissions CALENDAR READ_CALENDAR ,WRITE_CALENDAR CAMERA CAMERA CONTACTS READ_CONTACTS,WRITE_CONTACTS,GET_ACCOUNTS LOCATION ACCESS_FINE_LOCATION,ACCESS_COARSE_LOCATION MICROPHONE RECORD_AUDIO PHONE READ_PHONE_STATE…… SMS SEND_SMS, RECEIVE_SMS,READ_SMS,RECEIVE_WAP_PUSH,RECEIVE_MMS STORAGE READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE

6. 消息对像:intents and intent filters,主要的应用组件在activity,service,broadcast,包括显式的消息对像(explicit intents),隐式的消息对象(implicit intents),隐式的就是没有指定Intent的组件名字,需要Android根据Intent中的Action、data、Category等来解析匹配。而目标组件(Activity、Service、Broadcast Receiver)怎通过设置他们的Intent Filter来界定其处理的Intent。如果一个组件没有定义Intent Filter,那么它只能接受处理显示的Intent,只有定义了Intent Filter的组件才能同时处理隐式和显示的Intent。

6.1为了确保你的APP安全,总是用一个显式的消息对象来启动一个服务,而且不声明intent filters。

6.2 if you want your activity to receive implicit intents, it must include a category for “android.intent.category.DEFAULT

6.3 URI(Uniform Resource Identifier)

For example:

格式:< scheme >://< host >:< port >/< path >

content://com.example.project:200/folder/subfolder/etc

In this URI, the scheme is content, the host is com.example.project, the port is 200, and the path is folder/subfolder/etc

0 0
原创粉丝点击