Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Direct internet connection on Android Wear?

I tried to build an app showing some pictures from the internet.

I used a function, which works great on my Phone (Galaxy S3 - Android 4.3) but on the watch i get a java.io.EOFException exception.

The code (works on phone):

private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
    ImageView bmImage;

    public DownloadImageTask(ImageView bmImage) {
        this.bmImage = bmImage;
    }

    protected Bitmap doInBackground(String... urls) {
        String urldisplay = urls[0];
        Bitmap mIcon11 = null;
        try {
            InputStream in = new java.net.URL(urldisplay).openStream();
            mIcon11 = BitmapFactory.decodeStream(in);
        } catch (Exception e) {
            //Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return mIcon11;
    }

    protected void onPostExecute(Bitmap result) {
        bmImage.setImageBitmap(result);
    }
}

Other functions throw a org.apache.http.NoHttpResponseException The watch is paired and online as i can use voice commands and search the web etc.

So the question: Can i access the web directly from Android Wear or do need to handle all these tasks on my phone? Or is there something wrong with my setup?

like image 801
Draagon Avatar asked Jul 08 '14 08:07

Draagon


People also ask

Can Smartwatches connect to Internet?

Most of the latest smartwatches can connect to Wi-Fi. If you don't see a Wi-Fi setting in the settings list, then it can't use Wi-Fi.

Can you install APK on Wear OS?

While Wear OS is rich in features, it's not as polished as watchOS on the Apple Watch. However, just like all Android phones, it's customizable. And along with the apps on the Play Store, you can also sideload APK files just like you can on a smartphone.


1 Answers

Android Wear Devices have no direct access to the internet. If you want to access the web, you should do so using your companion app. You can use the Data Layer API to transfer data back and forth between the wearable and the handheld. The Data Layer API has built-in support for transferring assets (mostly images, but basically you transfer anything other binary data).

EDIT: As of Android Wear 2.0, it is possible to directly access the internet using regular network APIs. See the Android Wear 2.0 Developer Preview documentation for details. Android Wear 2.0 has not yet been released yet, refer to the Developer Preview Program Overview for a timeline.

like image 90
Peter Friese Avatar answered Sep 22 '22 02:09

Peter Friese