Cordova - How to display 360 images on Android


JcDenton86

I'm building a cordova app that gets JSON data from a server. One message I received was the URL of 360 images online. I need to display these images in Photo Sphere Viewer (for Android). I've looked at this API (requires cordova google play services plugin) and this library, but I haven't managed to use them successfully inside the app. Does anyone know a way to do this? Can I open this type of image natively? Thanks in advance

JcDenton86

I actually managed to get it to work. I'll post the solution if anyone finds it useful. Also created a plugin for this which can be found here

After creating a simple plugin, I call the plugin class from cordova which downloads using AsyncTaskthe image from the URL and onPostExecutecalls the Panorama activity that shows the viewer.

Intent intent = new Intent(cordova.getActivity().getApplicationContext(), PanoramaActivity.class);
intent.putExtra("filepath", file.getAbsolutePath());
cordova.getActivity().startActivity(intent);.

PanoramaActivity.java

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.panorama.Panorama;
import com.google.android.gms.panorama.PanoramaApi.PanoramaResult;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import java.io.File;
import android.os.Environment;

public class PanoramaActivity extends Activity implements  ConnectionCallbacks, OnConnectionFailedListener{
File file;

@Override
public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
    mClient = new GoogleApiClient.Builder(this, this, this)
            .addApi(Panorama.API)
            .build();

    Intent i= getIntent();
    Bundle b = i.getExtras();
    file = new File(b.getString("filepath"));
     @Override
public void onStart() {
    super.onStart();
    mClient.connect();
}

@Override
public void onConnected(Bundle connectionHint) {
    Uri uri = Uri.fromFile(file);//Uri.parse(path);//Uri.fromFile(file);
    Panorama.PanoramaApi.loadPanoramaInfo(mClient, uri).setResultCallback(
            new ResultCallback<PanoramaResult>() {
        @Override
        public void onResult(PanoramaResult result) {
            if (result.getStatus().isSuccess()) {
                Intent viewerIntent = result.getViewerIntent();
                Log.i(TAG, "found viewerIntent: " + viewerIntent);
                if (viewerIntent != null) {
                    startActivity(viewerIntent);
                }
            } else {
                Log.e(TAG, "error: " + result);
            }
        }
    });
}

@Override
public void onConnectionSuspended(int cause) {
    Log.i(TAG, "connection suspended: " + cause);
}

@Override
public void onConnectionFailed(ConnectionResult status) {
    Log.e(TAG, "connection failed: " + status);
}

@Override
public void onStop() {
    super.onStop();
    mClient.disconnect();
    Log.e(TAG, "ON Stop ");
}

Related


Cordova - How to display 360 images on Android

JcDenton86 I'm building a cordova app that gets JSON data from a server. One message I received was the URL of 360 images online. I need to display these images in Photo Sphere Viewer (for Android). I've looked at this API (requires cordova google play service

Cordova - How to display 360 images on Android

JcDenton86 I'm building a cordova app that gets JSON data from a server. One message I received was the URL of 360 images online. I need to display these images in Photo Sphere Viewer (for Android). I've looked at this API (requires cordova google play service

Cordova - How to display 360 images on Android

JcDenton86 I'm building a cordova app that gets JSON data from a server. One message I received was the URL of 360 images online. I need to display these images in Photo Sphere Viewer (for Android). I've looked at this API (requires cordova google play service

How to display images in Meteor Cordova app on Android?

Dagasoin As shown in this screenshot, I can access the image from the Chrome desktop, but not in Xwalk. However, assets exist in assets/www/application/appand.meteor/local/build/programs/web.cordova/app The actual path to the image is generated by prepending t

How to display local://images in ionic framework + cordova?

Think big Does anyone know how to use Ionic ( http://ionicframework.com/docs/ ) to display a local image packaged in a Cordova container ? I'm currently getting this error when the app is running on the device: GET insecure: local:///img/thumbs/myImage.jpg Unh

How to insert and display images in Android?

Ada I want to insert and display images. But I have some errors. Why do I have a mistake on the word "with"? UsersRef.child(currentUserID).addValueEventListener(new ValueEventListener(){ @Override public void onDataChange(DataSnapshot dataSnapshot){

How to display a 360 degree panorama from an Android app

Libathos I want to display a panorama from my android app, the panorama is online and I loaded its url on the webview but it's not working. It's just part of it, it doesn't turn or turn upside down. I don't know where to start, can you point me in the right di

How to display images from database in Android ImageView

Master 123 Hi in my app i am getting json response in that image. This image i want to display in android imageview. In that image I want to set for imageView. Image": "547150_156322317826149_1332901104_n.jpg who can help me binary people Well, I'm assuming yo

How to display images in React Native Android App?

funny clown I want the image to take up the full width of the device screen. I've tried multiple CSS codes but it doesn't take the full width of the screen. code: <View style={styles.container}> <View> <Image source={require

How to display multiple images in imageview in android

sapno I am trying to display several images in an activity and the user can view them by scrolling. I did this by adding two ImageViews for the two images, but there is a large space/gap between the two images, which seems very unwise. solve this problem. Can

How to display database images in Glide for Android?

make mistakes SqliteDatabaseI have one in my application . In this database I save Stings and Blobs (for saving images) . The image is saved in the application using byte[] . I convert this image to Bitmap with the help of the following code: byte[] Recycl

How to display images in React Native Android App?

funny clown I want the image to take up the full width of the device screen. I've tried multiple CSS codes but it doesn't take the full width of the screen. code: <View style={styles.container}> <View> <Image source={require

How to display images in React Native Android App?

funny clown I want the image to take up the full width of the device screen. I've tried multiple CSS codes but it doesn't take the full width of the screen. code: <View style={styles.container}> <View> <Image source={require

How to display random images on android screen

artist I have 7 images in drawable folder. I want to display them randomly on the screen. I am new to graphics. Right now it just shows one image on the screen. How can I display random images on the screen? thanks public class MyGraphics extends SurfaceView i

How to display images from database in Android ImageView

Master 123 Hi in my app i am getting json response in that image. This image i want to display in android imageview. In that image I want to set for imageView. Image": "547150_156322317826149_1332901104_n.jpg who can help me binary people Well, I'm assuming yo

How to display images without Surfaceflinger on Android

Xylene How to draw something before SurfaceFligner launches on Android? In this case it's some kind of legacy Linux with a framebuffer device, so accessing the framebuffer directly should work. How to use HWComposer directly and how to use egl directly? light

How to display multiple images in imageview in android

sapno I am trying to display several images in an activity and the user can view them by scrolling. I did this by adding two ImageViews for the two images, but there is a large space/gap between the two images, which seems very unwise. solve this problem. Can

How to display images from web in android

Pinnacle's feet How to load image from url and then display it in view in android and java? I've tried synchronizing HTTP requests using AsyncTasks with various different code samples. Here is the last thing I tried: public Object fetch() throws MalformedURLEx

How to display images from database in Android ImageView

Master 123 Hi in my app i got json response in that image. This image i want to display in android imageview. In that image I want to set for imageView. Image": "547150_156322317826149_1332901104_n.jpg who can help me Ahmad MOUSSA Well, I'm assuming you're get

How to display images in React Native Android App?

funny clown I want the image to take up the full width of the device screen. I've tried multiple CSS codes but it doesn't take the full width of the screen. code: <View style={styles.container}> <View> <Image source={require

How to display images on Google Maps in Android Studio

username I searched a lot about this but didn't get what I was looking for. I'm using Android Studio, I know how to use Google Maps and GPS, but I want to put a camera icon to use the camera in the phone, when the user takes a photo, the app will save the acti

How to display images from database in Android ImageView

Master 123 Hi in my app i got json response in that image. This image i want to display in android imageview. In that image I want to set for imageView. Image": "547150_156322317826149_1332901104_n.jpg who can help me Ahmad MOUSSA Well, I'm assuming you're get

How to display images from web in android

Pinnacle's feet How to load image from url and then display it in view in android and java? I've tried synchronizing HTTP requests using AsyncTasks with various different code samples. Here is the last thing I tried: public Object fetch() throws MalformedURLEx

How to display images without Surfaceflinger on Android

Xylene How to draw something before SurfaceFligner launches on Android? In this case it's some kind of legacy Linux with a framebuffer device, so accessing the framebuffer directly should work. How to use HWComposer directly and how to use egl directly? light

display large images in android

Royal Dragon I'm trying to display a large image at 4kpx roughly in 4kpx. I want to allow the user to scroll, and use pinch to zoom. I have tried the following so far: WebView webview = (WebView) findViewById(R.id.webView); String data = "<body>" + "<i

Display web images in Android

Virgilio Falla I tried to load a jpg image in the image view but couldn't get the image, I debugged the code and I guess there is something wrong with the permissions, but when I tried it from another public website I had the same problem. I use these two exam

Display web images in Android

Virgilio Falla I tried to load a jpg image in the image view but couldn't get the image, I debugged the code and I guess there is something wrong with the permissions, but when I tried it from another public website I had the same problem. I use these two exam

Display web images in Android

Virgilio Falla I tried to load a jpg image in the image view but couldn't get the image, I debugged the code and I guess there is something wrong with the permissions, but when I tried it from another public website I had the same problem. I use these two exam

Display web images in Android

Virgilio Falla I tried to load a jpg image in the image view but couldn't get the image, I debugged the code and I guess there is something wrong with the permissions, but when I tried it from another public website I had the same problem. I use these two exam