如何使用 android 工作室为 android 项修改 android 应用程序

How to modify android app for android of things using android studio

我已经使用 android studio 为 android 设备(API 23 级及以上)制作了 android 应用程序。现在我想为 Android of Things(AOT) 修改该应用程序,以便我可以 运行 在安装了 AOT 的 Raspberry PI3 上使用它。

为了在 AOT 中成功 运行 应用程序,我必须在我的 android 工作室项目中更改哪些地方?

根据guidlines

将依赖项目添加到您的应用级 build.gradle 文件:

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

将 Things 共享库条目添加到应用程序的清单文件并声明一个家 activity:

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

除了亚历山大, 在项目 build.gradle 中添加:在存储库中:

maven { url 'https://maven.google.com'}

并考虑权限陷阱: 它们首先在设备重启后授予,而不是在安装应用程序后授予