Android Things 开发

来源:互联网 发布:网络问诊平台 编辑:程序博客网 时间:2024/05/21 12:44

Android Things简介
Android Things 开发
开发板刷Android Things系统


Building Your First Device

Create an Android Things Project
创建一个Android Things 应用程序

1,Prerequisites:开发的前提条件

Before you begin building apps for Things, you must:

1,Update your SDK tools to version 24 or higher The updated SDK tools enable you to build and test apps for Things.2,Update your SDK with Android 7.0 (API 24) or higher The updated platform version provides new APIs for Things apps.3,Create or update your app project In order to access new APIs for Things, you must create a project or modify an existing project that targets Android 7.0 (API level 24) or higher

1,更新sdk中build-tools的版本(24或者更高),更新后的sdk可以让你构建和测试你的Things应用程序。
2,更新sdk中Android系统版本为Android 7.0(24)或者更高,它提供了开发Android Things应用程序新的API。
3,当你创建或者修改现有项目的时候,项目的API要是24或者更高,这样你才能访问Things的API。

2,Add the library
androidthings不是Android sdk中的一部分,它是以支持库的方式存在,所以你要对其进行配置。
1,Add the dependency artifact to your app-level build.gradle file:

dependencies {    ...    provided 'com.google.android.things:androidthings:0.1-devpreview'}

2,Add the things shared library entry to your app’s manifest file:

<application ...>    <uses-library android:name="com.google.android.things"/>    ...</application>

uses-library :把程序包类装载器中需要包含的库代码通知系统

3,Declare a home activity
配置Activity

Action: ACTION_MAINCategory: CATEGORY_DEFAULTCategory: IOT_LAUNCHER
<application    android:label="@string/app_name">    <uses-library android:name="com.google.android.things"/>    <activity android:name=".HomeActivity">        <!-- Launch activity as default from Android Studio -->        <intent-filter>            <action android:name="android.intent.action.MAIN"/>            <category android:name="android.intent.category.LAUNCHER"/>        </intent-filter>        <!-- Launch activity automatically on boot -->        <intent-filter>            <action android:name="android.intent.action.MAIN"/>            <category android:name="android.intent.category.IOT_LAUNCHER"/>            <category android:name="android.intent.category.DEFAULT"/>        </intent-filter>    </activity></application>

至此怎么创建一个Android Things应用程序开发完毕。

测试:写一个activity,随便打印log,按照以上配置,然后运行程序,看Console控制台输出。


在往下就是需要连接外设及和外设进行交互。

Connect the Hardware

Interact with Peripherals

Integrate Peripheral Drivers

0 0