首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >应用程序在使用`com.android.future.usb.accessory`库时不会启动

应用程序在使用`com.android.future.usb.accessory`库时不会启动
EN

Stack Overflow用户
提问于 2015-10-06 05:57:25
回答 1查看 841关注 0票数 17

我跟随本指南在API 10上使用com.android.future.usb库。

我做了以下工作:

  • 从SDK Manager安装了Google 10:

  • 选择Google 10作为我的项目构建目标:

  • 将这些添加到manifest

<uses-feature android:name="android.hardware.usb.accessory" /> (直接子<manifest>)

<uses-library android:name="com.android.future.usb.accessory" /> (<application>之子)

<meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" android:resource="@xml/accessory_filter" /> (第一activity之子)

  • 创建了res/xml/accessory_filter.xml,如提到的这里

通过这样做,我可以使用com.android.future.usb及其子类。但问题是,应用程序不会在manifest更改之后启动。

这是一个根设备,操作系统将此应用程序配置为在设备启动时自动启动。

我应该做任何其他的配置来使这个工作吗?也许应该在固件中做些什么?

编辑:

这是与usb相关的所有内容的logcat

代码语言:javascript
复制
USB mass storage support is not enabled in the kernerl
usb_configuration switch is not enabled in the kernerl
Volume usb state changing -1 (Initializing) -> 0 (No-Media)
Ignoring unknown switch 'usb_connected'
Package com.example.gui requires unavailable shared library com.android.future.usb.accessory: failing!
Skipping unknown volume '/mnt/usb'
USB Service
This kernel does not have USB configuration switch support
EN

回答 1

Stack Overflow用户

发布于 2015-11-05 00:31:48

不清楚你所说的the application won't start是什么意思。

如果您期望应用程序启动automatically on device startup。这里有这样做的说明:如何在启动时启动应用程序?

如果问题是应用程序无法编译,则需要更多有关所遇到错误的信息。

您提到您根据所提供的链接对清单进行了更改。该示例还包括清单中活动元素的intent-filter标记,您没有提到这一点。因此,清单中的活动元素将有两个意图过滤器:

代码语言:javascript
复制
        <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
        </intent-filter>

        <meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
                   android:resource="@xml/accessory_filter" />

    </activity>

因此,您的应用程序没有启动可能是因为您从活动清单中删除了主/启动程序意图筛选器?

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32962708

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档