Reputation: 641
Is it possible to listen for a button press from a background app running on a Wear device? I would like to create a shortcut for an Android app so that when the user presses a physical button on a watch, the app opens on a paired device.
Thank you, Donny
Upvotes: 2
Views: 280
Reputation: 103
add to manifest receiver
<receiver
android:name=".services.utils.SearchLongPressReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.SOS_LONG_PRESS" />
</intent-filter>
</receiver>
create BroadcastReceiver
class SearchLongPressReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
context.startActivity(Intent(context, SosActivity::class.java))
}
}
Upvotes: -1