【问题标题】:Possible to make android watch face a picture from my gallery?可以从我的画廊中制作 android 表盘的图片吗?
【发布时间】:2017-07-28 20:30:54
【问题描述】:

是否可以制作一个应用程序,从用户手机的图库中拍摄照片并将其转换为安卓可穿戴表盘?

我一直在阅读这些 Android 文章

https://developer.android.com/training/wearables/watch-faces/index.html

https://developer.android.com/training/wearables/watch-faces/drawing.html

如果我可以让用户从图库中选择一张图片并将其转换为位图,那么将其设置为表盘似乎是合理的。当谈到 Android 和 apks 时,我绝对是一个初学者程序员。 来自更高级的 Android 开发人员的确认会很棒。

现在我感到困惑的是,是否会在用户的手机上选择图片并将其发送到 android 可穿戴应用程序,或者可穿戴应用程序是否能够访问用户手机的图库并选择它直接地。有谁知道可穿戴应用程序是否可以访问用户手机的图库?

假设我已经有选择的图像的参考,它会是这样的吗?如我错了请纠正我。 (摘自“初始化表盘元素”下的第二篇文章

@Override
public void onCreate(SurfaceHolder holder) {
    super.onCreate(holder);

    // configure the system UI (see next section)
    ...

    // load the background image
    Resources resources = AnalogWatchFaceService.this.getResources();
    //at this point the user should have already picked the picture they want
    //so set "backgroundDrawable" to the image the user picture
    int idOfUserSelectPicture = GetIdOfUserSelectedPictureSomehow();
    Drawable backgroundDrawable = resources.getDrawable(idOfUserSelectPicture, null);
    //original implementation from article
    //Drawable backgroundDrawable = resources.getDrawable(R.drawable.bg, null);
    mBackgroundBitmap = ((BitmapDrawable) backgroundDrawable).getBitmap();

    // create graphic styles
    mHourPaint = new Paint();
    mHourPaint.setARGB(255, 200, 200, 200);
    mHourPaint.setStrokeWidth(5.0f);
    mHourPaint.setAntiAlias(true);
    mHourPaint.setStrokeCap(Paint.Cap.ROUND);
    ...

    // allocate a Calendar to calculate local time using the UTC time and time zone
    mCalendar = Calendar.getInstance();
}

感谢您的任何帮助。

【问题讨论】:

  • 您的手表应用程序将通过数据层developer.android.com/training/wearables/data-layer/index.html 与您的安卓手机/平板电脑应用程序进行通信。我会先在手机/平板电脑应用程序上进行挑选,然后在手表一样小的屏幕上进行尝试。祝你好运。
  • 谢谢,在手表上挑选图像是个好主意,因为可用的屏幕空间很少。因此,手机应用程序肯定会选择图片,然后将该数据发送到手表应用程序。

标签: android image gallery wear-os watch-face-api


【解决方案1】:

实现这一点的方法是创建一个在手机上运行的配置 Activity,它从您设备上的图像中挑选。然后您可以通过数据层http://developer.android.com/training/wearables/data-layer/index.html将此图像作为资产发送,它将在手表端接收,然后您可以将其设置为表盘背景。

Android Wear 设备无法在您的手机上查看照片集,它们是完全独立的设备,默认情况下不会共享任何内容,除非您编写了执行此操作的应用程序。

数据层示例展示了如何在手机上拍照,然后将其发送到可穿戴设备:https://github.com/googlesamples/android-DataLayer

【讨论】:

  • 非常感谢您提供这些信息,这绝对会有所帮助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多