当前位置: 首页 > 编程日记 > 正文

树莓派Android Things物联网开发:创建一个Things项目

【转载请注明出处: http://blog.csdn.net/leytton/article/details/77854144

《树莓派Android Things物联网开发》系列文章专栏 http://blog.csdn.net/column/details/17741.html

树莓派Android Things物联网开发:入门及资料汇总

树莓派Android Things物联网开发:创建一个Things项目

树莓派Android Things物联网开发:树莓派GPIO引脚图

树莓派Android Things物联网开发:按键中断及消抖

树莓派Android Things物联网开发:已知Bug发行说明

树莓派Android Things物联网开发:GitHub案例程序汇总


Android Things应用程序结构与Android手机或平板电脑相同。这意味着你可以修改现有的App直接在Android Things中运行,或者你可以基于之前掌握的Android技术来开Things应用。

本课程介绍了Android Things开发环境准备工作,以及一些必要的修改,以使应用在Android Things中运行。

准备工作


在开始构建Things应用程序的之前,你必须:

  • 更新SDK工具到25.0.3或更高版本 更新版本的SDK工具,可以帮您构建和测试应用应用。
  • 更新SDK到Android 8.0(API 26)或更高版本 更新版本的SDK平台提供新的Things应用API。
  • 创建或更新您的应用项目, 为了在新的Things应用API,创建的项目或者已有项目的SDK版本必须升级到Android 8.0(API26)或更高。

添加依赖库


Android Things的API不包含在Android SDK中。我们要声明Things的依赖库:

  1. build.gradle文件中添加依赖库:

    dependencies {...provided 'com.google.android.things:androidthings:0.5.1-devpreview'
    }
    
  2. 在AndroidManifest.xml添加共享库:

    <application ...><uses-library android:name="com.google.android.things"/>...
    </application>
    
注意:添加provided依赖,能确保构建工具在编译时不会将共享库复制到APK中。加入<uses-library> 能使这个共享库在应用程序运行时有效。总之,这些设置能使您的应用程序使用设备系统提供的共享库。

声明入口Activity


想要应用程序在Android Things嵌入式设备中开机启动,那么就必须在其AndroidManifest.xml文件中声明作为主入口点,并且添加intent-filter包含以下属性:

  • Action: ACTION_MAIN
  • Category: CATEGORY_DEFAULT
  • Category: IOT_LAUNCHER

为了便于开发,这个Activity也应该包括 CATEGORY_LAUNCHER 这个intent-filter,Android Studio在部署或调试时会启动它作为默认入口。

<applicationandroid:label="@string/app_name"><uses-library android:name="com.google.android.things"/><activity android:name=".HomeActivity"><!-- Android Studio 默认启动的Activity --><intent-filter><action android:name="android.intent.action.MAIN"/><category android:name="android.intent.category.LAUNCHER"/></intent-filter><!-- 开机后自动启动的Activity --><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>

PS:如果本文对您有帮助,请点个赞让我知道哦~微笑


原文阅读需要科学上网

摘自https://developer.android.com/things/training/first-device/create-studio-project.html

Create an Android Things Project

Things apps use the same structure as those designed for phones and tablets. This similarity means you can modify your existing apps to also run on embedded things or create new apps based on what you already know about building apps for Android.

This lesson describes how to prepare your development environment for Android Things, and the required changes to enable app to run on embedded things.

Prerequisites


Before you begin building apps for Things, you must:

  • Update your SDK tools to version 25.0.3 or higher The updated SDK tools enable you to build and test apps for Things.
  • Update your SDK with Android 8.0 (API 26) or higher The updated platform version provides new APIs for Things apps.
  • 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 8.0 (API level 26) or higher.

Add the library


Android Things devices expose APIs through support libraries that are not part of the Android SDK. To declare the Things Support Library dependency in your app:

  1. Add the dependency artifact to your app-level build.gradle file:

    dependencies {...provided 'com.google.android.things:androidthings:0.5.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>
    
Note: Add the provided dependency to ensure that the build tools don't copy the shared library into the APK at compile time. Add <uses-library> to make this prebuilt library available to the app's classpath at run time. Together, these additions allow you to build against an on-device, shared library.

Declare a home activity


An application intending to run on an embedded device must declare an activity in its manifest as the main entry point after the device boots. Apply an intent filter containing the following attributes:

  • Action: ACTION_MAIN
  • Category: CATEGORY_DEFAULT
  • CategoryIOT_LAUNCHER

For ease of development, this same activity should include a CATEGORY_LAUNCHER intent filter so Android Studio can launch it as the default activity when deploying or debugging.

<applicationandroid: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>



转载于:https://www.cnblogs.com/leytton/p/8253241.html

相关文章:

使用JDBC进行MySQL 5.1的数据连接、查询、修改等操作练习。

目录 顺序查找 控制游标 条件与排序查询 1. where子语句 一般格式&#xff1a; 2. 排序 更新、添加与删除操作 1.更新 2.添加 3.删除 通用查询 顺序查找 所谓顺序查询&#xff0c;是指ResultSet对象一次只能看到一个数据行&#xff0c;使用 next()方法移到下一个数据行…

Tensorflow多线程输入数据处理框架(一)——队列与多线程

参考书 《TensorFlow&#xff1a;实战Google深度学习框架》&#xff08;第2版&#xff09; 对于队列&#xff0c;修改队列状态的操作主要有Enqueue、EnqueueMany和Dequeue。以下程序展示了如何使用这些函数来操作一个队列。 #!/usr/bin/env python # -*- coding: UTF-8 -*- # c…

编译器错误信息: CS0016

编译器错误信息: CS0016: 未能写入输出文件,..\Temporary ASP.NET Files\WebApp\d087da43\c12930d8\9ze28k_8.dll”--拒绝访问 编译器错误信息: CS0016: 未能写入输出文件“d:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\5177u\d087da43\c12930d8\9ze…

Visual Studio 2008 Samples Page

Visual Studio 2008 Samples Page http://msdn.microsoft.com/zh-cn/bb330936(en-us).aspx 如何实现 - 常规开发http://msdn.microsoft.com/zh-cn/library/ms246578.aspx Visual Studio 2008http://msdn.microsoft.com/zh-cn/library/aa187917.aspx .NET Framework 3.5http://m…

iOS开发网络篇—HTTP协议

说明&#xff1a;apache tomcat服务器必须占用8080端口 一、URL 1.基本介绍 URL的全称是Uniform Resource Locator&#xff08;统一资源定位符&#xff09; 通过1个URL&#xff0c;能找到互联网上唯一的1个资源 URL就是资源的地址、位置&#xff0c;互联网上的每个资源都有一个…

操作系统导论部分章节习题

进程 一。单选题&#xff08;共1题&#xff0c;10.0分&#xff09; 当某个进程进行系统调用以通过网络传输TCP数据包时&#xff0c;以下哪些步骤不会总是发生&#xff1f; A进程进入内核模式。 B&#xff0c;CPU的程序计数器转移到地址空间的内核部分。 C&#xff0c;该进…

Go-技篇第一 技巧杂烩

Go-技篇第一 技巧杂烩一句话技巧把你面向对象的大脑扔到家里吧&#xff0c;去拥抱接口。mikegehard学习如何使用Go的方式做事&#xff0c;不要把别的的编程风格强行用在Go里面。DrNic多用接口总比少用好。evanphx拥抱这种简洁、并行、工整的语言。francesc阅读官网golang.org上…

Visual Studio 2008 到底有多强?漫画告诉你 !

插入数据需要无数个SQL语句支持&#xff0c;而现在&#xff0c;你只需要有一个强大的LinQ巴士&#xff0c;就直接一次性全搞定&#xff0c;方便快捷 " 强大的中转站&#xff0c;帮你解决额外的问题&#xff0c;数据传输选择最优路径&#xff0c;完成工作。数据给了WCF&a…

使用c#生成高品质小空间的缩略图

dot自带的生成缩略图的方法是Bitmap.GetThumbnailImage这个方法生成的缩略图不够清晰&#xff0c;一般我们会使用Graphics高质量插值发生成清晰的缩略图&#xff0c;这时候大小会不尽人意&#xff0c;怎么办&#xff1f;我们可以使用jpeg压缩的方法压缩一下图片&#xff0c;这样…

将Project的内容导出成单独的XPO文件

AX跟VSS整合的版本管理可以通过创建知识库将当前层的代码全部签入到VSS中&#xff0c;但是如果不是一个团队开发solution&#xff0c;而是针对客户的需求随时做得一些小改动&#xff0c;一般都希望以Project的形式组织代码和发布代码。AX与VSS的整合没有提供一种方法可以将一个…

.Net Core MVC初学习

.net core已经出来很长一段时间了&#xff0c;没有很好的学习过&#xff0c;现在工作不那么忙了&#xff0c;参考官方文档&#xff0c;在这里记录自己的学习过程&#xff01; ASP.NET Core 是一个跨平台的高性能开源框架&#xff0c;用于生成基于云且连接 Internet 的新式应用程…

编译原理考点复习

名词填空、名词解释、解答题&#xff1a; 文法是什么&#xff1f;文法、句子、句型、确定有穷自动机&#xff08;DFA&#xff09;、非确定有穷自动机&#xff08;NFA&#xff09;的定义&#xff1f;编译过程主要有哪些功能模块&#xff1f;有什么辅助模块&#xff08;表格管理…

网络工程师如何才能实现职位晋升

一、如何在公司得到攀升的机会&#xff1f;如果不想保持低月薪&#xff0c;就运用你的技术积极参与公司的业务发展从最近我们公司招生来看&#xff0c;一个很明显的问题阴魂不散的笼罩在“网络工程师”这个行业。问题的根本是对网络工程师职业前途的严重误解。很多人认为目前的…

Linux中/etc/resolv.conf文件简析

https://blog.csdn.net/lcr_happy/article/details/54867510转载于:https://www.cnblogs.com/answercard/p/10354514.html

第二章 Servlet核心技术 实训二

question.html <!DOCTYPE html> <html> <head> <meta charset"UTF-8"> <title>简单测试</title> </head> <body> <p>请回答下面的问题&#xff1a;</p> <form action"simpletest.do"meth…

BZOJ 4025 二分图

题目大意 给定一个\(n\)个点, \(m\)条边的无向图, 每条边在一定时间范围内存在. 要你判断每个时间点这张图是否为二分图.\(n \le 10^5\)\(m \le 2 \times 10^5\) Solution 我们考虑一个合法的二分图有什么性质: 图中不存在奇环, 即环上边数(点数)为奇数的环. 考虑如何判断每个时…

javascript对象之window对象详解

frames 表示当前窗口中所有frame对象的数组 status 表示浏览器的状态行信息 defaultstatus 表示浏览器的状态行信息 history 表示当前窗口的历史记录,这可以引用在网页导航中 closed 表示当前窗口是否关闭的逻辑值 document 表示当前窗口中显示的当前文档对象 location 表示当前…

Wsus简单笔记

一&#xff1a;安装前的要求1&#xff1a;iis6.0以上&#xff0c;bits、Asp.net2.02:sql20053:Microsoft Management Console 3.04:microsof report viewer redistributable 20055&#xff1a;ntsf分区二&#xff1a;安装1&#xff1a;过程比较简单&#xff0c;注意设置本地补丁…

机器学习-Sklearn

Scikit learn 也简称 sklearn, 是机器学习领域当中最知名的 python 模块之一. Sklearn 包含了很多种机器学习的方式:Classification 分类 Regression 回归 Clustering 非监督分类 Dimensionality reduction 数据降维 Model Selection 模型选择 Preprocessing 数据预处理 我们总…

[翻译]自动维护索引重新生成组织的SQL批处理语句

脚本来自《Inside Server 2005 T-SQL Programming》 SET NOCOUNT ON;DECLARE objectid int;DECLARE indexid int;DECLARE partitioncount bigint;DECLARE schemaname nvarchar(258);DECLARE objectname nvarchar(258);DECLARE indexname nvarchar(258);DECLARE partitionnum bi…

DTrace memory leak 内存泄露

http://blog.sina.com.cn/s/blog_538040b70100eecn.html如下程序用于跟踪&#xff0c;在分配和回收都会触发探针 #!/usr/sbin/dtrace -s pid$target:libc:malloc:entry{ self->trace 1; self->size arg0;}pid$target:libc:malloc:return/self->trace 1/{ …

Spark的安装和使用

Spark2.1.0入门&#xff1a;Spark的安装和使用 Hadoop安装教程_单机/伪分布式配置_Hadoop2.6.0(2.7.1)/Ubuntu14.04(16.04) 手把手教你在VirtualBox中与主机共享文件夹

SQL Server 2005系列教学(6) 多表操作及子查询

多表查询&#xff1b;<?xml:namespace prefix o ns "urn:schemas-microsoft-com:office:office" />人事表&#xff1a; 公司表&#xff1a;姓名性别年龄姓名公司地址张三男25李四女25张三新…

(点)分治学习笔记

哗我看了一下好像没有很详细专门讲分治的blog&#xff1f;那就主要先学一下点分治吧&#xff0c;其他的……等我记得把C一本通带到机房来再说吧先咕着啦 写在前面 刷题进度 入门题&#xff08;0/3&#xff09; 好题(0/9) 问题解决进度 Q1 Q2 正文 淀粉质 点分治 点分治就是在一…

十五个步骤收获学习的习惯

"真正的发现的航程&#xff0c;并非是在寻找新的土地,而且用新的视界去寻找"--普鲁斯特 "智慧日进者方值得尊敬。"-林肯 "我从不让我在学校所学的干扰我的教育"-马克吐温 如果公立学校尚未摧残你的灵魂&#xff0c;那么学习是一项极佳的活动。它…

熟悉scala命令,scala语言运行超级素数和猴子大王

实验目的 在Linux操作系统中安装Scala输入“scala”命令&#xff0c;熟悉地运行Scala解释器scala语言运行超级素数和猴子大王实验仪器 Virtualbox管理器 实验框图&#xff08;电路图/流程图&#xff09; 在Windows中使用VirtualBox安装Ubuntu&#xff0c;安装好scala后&#xf…

安装mayavi和VTK库的血泪史

一开始安装VTK库是从官网上下载&#xff0c;但是怎么都找不到whl文件&#xff0c;只有exe文件&#xff08;vtkpython-7.1.1-Windows-64bit.exe&#xff09;。下载安装之后再PyCharm中import vtk出错。当时认为是文件出错。后来在一篇博客&#xff08;Python下VTK 编程 - lj6952…

Python LEGB (Local, Enclosing, Global, Build in) 规则

1 Local 一个函数定义了一个 local 作用域; PyFrameObject 中的 f_local 属性2 Global 一个 module 定义了一个 global 作用域; PyFrameObject 中的 f_global 属性.3 BuiltIn open, dir 的作用域等等, python 最顶层的作用…

图解DotNet框架系列

图解.Net框架系列(索引贴) (声明:本系列已完成,故索引帖重发) 众所周知,DotNet框架是非常庞大的,光项目创建时的种类就有WPF,WCF,WF这三种最新的技术,还有以前的Web,WinForm,Service,Mobile等等. 这么复杂和庞大的框架,用文字来描述是远远不够的,所以我准备写一系列图文并茂的文…

【Linux基础】文件处理实例

1.文件拆分 //每4000行拆分一个文件 split -l 4000 epms_t_ep_fx_stl_xy_20190129.dat 2.行处理 //查找第二列为711611且第三列为711100记录&#xff0c;打印行号和整行数据 awk -F ‘^C’ {if ($3711100 && $2711611) print NR,$0 } epms_t_ep_fx_stl_xy_20190229.d…