Android 蓝牙配件可以强制设备启动应用程序吗?

发布于 2024-09-10 00:22:39 字数 103 浏览 4 评论 0原文

我想知道是否可以开发一个可以在您的设备上启动现有 Android 应用程序的硬件(例如可能通过蓝牙)。

我似乎找不到任何有关此类功能的文档。

有人遇到过这个吗?

I am wondering if a piece of hardware can be developed (probably over bluetooth for example) that could launch an existing android application on your device.

I can't seem to find any documentation on this kind of functionality.

Has anybody come across this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

作死小能手 2024-09-17 00:22:39

看起来您可以使用 ACTION_DISCOVERY_[STARTED|FINISHED] 方法注册广播接收器。 链接

要注册接收器,请进入项目的 AndroidManifest.xml 并添加接收器标签和一些权限标签:

    <application ...>

            <!-- Add your receiver class like so, and declare that you want to listen
                 for the DISCOVERY_FINISHED action -->
    <receiver android:name=".PUT_YOUR_CLASS_NAME_HERE(e.g. BluetoothReceiver)">
        <intent-filter>
            <action android:name="android.bluetooth.adapter.action.DISCOVERY_FINISHED" />
        </intent-filter>
    </receiver>

    </application>
    <!-- Add the permissions you might need here -->
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

然后您应该能够创建 BluetoothReceiver 类并重写 onReceive 方法。

Looks like there are ACTION_DISCOVERY_[STARTED|FINISHED] methods that you could register a broadcast receiver for. Link

To register the receiver, go into your project's AndroidManifest.xml and add the receiver tag and some permission tags:

    <application ...>

            <!-- Add your receiver class like so, and declare that you want to listen
                 for the DISCOVERY_FINISHED action -->
    <receiver android:name=".PUT_YOUR_CLASS_NAME_HERE(e.g. BluetoothReceiver)">
        <intent-filter>
            <action android:name="android.bluetooth.adapter.action.DISCOVERY_FINISHED" />
        </intent-filter>
    </receiver>

    </application>
    <!-- Add the permissions you might need here -->
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

you should then be able to create the BluetoothReceiver class and override the onReceive method.

烦人精 2024-09-17 00:22:39

这背后的理论如下:

  • 您应该生成一个 BroadcastIntent
  • BroadcastIntentBroadcastReceiver 接收
  • BroadcastReceiver启动一个应用程序。

我从未在 Android 上使用过蓝牙,但当有人尝试连接到您时应该会有广播。你可以听听这个。

The theory behind this is the following:

  • You should generate a BroadcastIntent
  • This BroadcastIntent is received by a BroadcastReceiver
  • The BroadcastReceiver launches an application.

I've never used Bluetooth with Android, but there should be a Broadcast when someone tries to connect to you. You could listen to that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文