简体   繁体   English

如何在手机和平​​板电脑的应用程序中让 android 佩戴振动?

[英]How to make android wear Vibrate in an app for phones and tablets?

I have made an interval timer app for phones and tablets.我为手机和平板电脑制作了一个间隔计时器应用程序。 I want to make my watch Vibrate too when the workout starts and stops.我也想让我的手表在锻炼开始和停止时振动。 Do you need to make full app for wear or can you just get your wear to Vibrate in the existing app?您是否需要制作完整的穿戴应用程序,还是可以在现有应用程序中将穿戴设备设置为 Vibrate?

If you show a notifcation for starting and finishing the workout it will be automatically shown on the wearable as well.如果您显示开始和结束锻炼的通知,它也会自动显示在可穿戴设备上。 You can add vibration to the notification with the NotificationCompat.Builder setVibrate(long[] pattern) method.您可以使用NotificationCompat.Builder setVibrate(long[] pattern)方法向通知添加振动。

If you only want to make the wearable vibrate and don't want to show a notification on your phone, your only option is to create a separate app for the wearable.如果您只想让可穿戴设备振动而不想在手机上显示通知,您唯一的选择就是为可穿戴设备创建一个单独的应用程序。

If your not familiar with developing separate apps for wearables, here you can find all the basic information for it:http://developer.android.com/training/wearables/apps/index.html如果您不熟悉为可穿戴设备开发单独的应用程序,您可以在这里找到它的所有基本信息:http ://developer.android.com/training/wearables/apps/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM