I am trying to develop a virtual tour android application. I have photosphere image in my local device. I need to open this image and allow the user to explore. But the image is not loading in the image view. Is there anyother way to load this image and take some actions on the image like scrolling or swiping.
You can use Photo Sphere Api's from Google play service. Below is example how to use it -
And follow below link for more info -
[http://android-developers.blogspot.in/2012/12/new-google-maps-android-api-now-part-of.html][1]
// This listener will be called with information about the given panorama.
OnPanoramaInfoLoadedListener infoLoadedListener =
new OnPanoramaInfoLoadedListener() {
#Override
public void onPanoramaInfoLoaded(ConnectionResult result,
Intent viewerIntent) {
if (result.isSuccess()) {
// If the intent is not null, the image can be shown as a
// panorama.
if (viewerIntent != null) {
// Use the given intent to start the panorama viewer.
startActivity(viewerIntent);
}
}
}
// If viewerIntent is null, the image is not a viewable panorama.
};
Create client instance and connect to it.
Once connected to the client, initiate the asynchronous check on whether
the image is a viewable panorama.
client.loadPanoramaInfo(infoLoadedListener, panoramaUri);
Related
I have a working implementation of Googles PanoramaAPI in my Application. Unfortunately, the implementation stopped working on Android 11.
The implementation looks like the following:
Uri uri = Uri.fromFile(file);
Panorama.PanoramaApi.loadPanoramaInfoAndGrantAccess(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);
finish();
}
} else {
Log.e(TAG, "error: " + result);
}
}
});
Following Situation:
When I make a panorama image on my smartphone and load it into the given implementation, it works. The image get's loaded from /storage/emulated/0/DCIM/Camera/*.jpg and the panorama view is shown without a problem.
When I Upload the same image on a server and download it through the app, the image get's stored on /storage/emulated/0/Android/data/<applicationId>/files/*.jpg. Unfortunately, the panorama view is not able to load the image and the viewerIntent is allways null.
For me, it looks like a permission problem on Android 11, but I don't know how to fix it. I don't want to download the image into a more public area of the phone. Does anyone has an idea how to fix it?
I suspect it is related to the introduction of Scoped Storage in Android 11, but I'm not sure.
I've managed to put together an alternative to the Panorama API using the VR Kit, which I've documented in my blog post with some code snippets.
The TLDR is this:
Replace your original ImageView with a VrPanoramaView
Use the VrPanoramaView's API to hide some options (optional)
Overlay an image button over the VrPanoramaView and use it to toggle between gyroscopic and touch modes
Use touch interception to support pinch zoom (this will be in a separate blog post)
Load your image into VrPanoramaView
I'm trying to take screenshot of current page and share via facebook, whats app, instagram, twitter etc., using phonegap. But was unable to do that properly.
I tried out this code but it doesn't work. Can anyone help me to solve this?
function report() {
let region = document.querySelector("body"); // whole screen
html2canvas(region, {
onrendered: function(canvas) {
let pngUrl = canvas.toDataURL();
let img = document.querySelector(".screen");
img.src = pngUrl; // pngUrl contains screenshot graphics data in url form
window.plugins.socialsharing.share(img.src);
// here you can allow user to set bug-region
// and send it with 'pngUrl' to server
},
});
}
Our App has a requirement to take multiple images and then display them for upload after the user has finished, Is this possible with IOS and Android camera. Not seeing any examples.
I have looked at many Cordova plugins, all seem to either support taking one image or selecting multiple from the gallery, not allowing taking multiple images with the camera.
If you have done this or know if this is possible, please help
You can use cordova-plugin-media-capture plugin.This plugin provides access to the device's audio, image, and video capture capabilities.
capture.captureImage
Start the camera application and return information about captured image files.
navigator.device.capture.captureImage(
CaptureCB captureSuccess, CaptureErrorCB captureError, [CaptureImageOptions options]
);
Description
Starts an asynchronous operation to capture images using the device's camera application. The operation allows users to capture more than one image in a single session.
The capture operation ends either when the user closes the camera application, or the maximum number of recordings specified by CaptureImageOptions.limit is reached. If no limit value is specified, it defaults to one (1), and the capture operation terminates after the user captures a single image.
When the capture operation finishes, it invokes the CaptureCB callback with an array of MediaFile objects describing each captured image file. If the user terminates the operation before capturing an image, the CaptureErrorCB callback executes with a CaptureError object featuring a CaptureError.CAPTURE_NO_MEDIA_FILES error code.
Example
// capture callback
var captureSuccess = function(mediaFiles) {
var i, path, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
path = mediaFiles[i].fullPath;
// do something interesting with the file
}
};
// capture error callback
var captureError = function(error) {
navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
};
// start image capture
navigator.device.capture.captureImage(captureSuccess, captureError, {limit:2});
I have used an answer from here
How should I give images rounded corners in Android?
However when created the picture with rounded edges it is being saved in my camera gallery as well as in a custom location that I have specified, any reason why this would happen or anyway to get rid of it automatically?
I don't want a picture being saved here.
Images are not saved in your device gallery - the gallery just displays all the images that are on your phone, UNLESS they are in storage associated with particular application. Use the following method do determine where you should save the images.
private File getAbosoluteFile(String ralativePath, Context context) {
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
return new File(context.getExternalFilesDir(null), ralativePath);
} else {
return new File(context.getFilesDir(), ralativePath);
}
}
It will store them in external storage associated with your application and they will seize being displayed in the device's gallery. Try this out with new image, because images are cached for a long time in the gallery application.
I am writing an app that is essentially a flipcard that shows word/hint on one side and picture on other side relevant to it.I am using viewflipper for the two views.Problem is that the picture loads from internet.App access the db,extracts url and then loads picture.That means the change in view takes as much time as it takes to download the picture.I want to flip card immediately and load picture so that user do not thinks that app is slow.Rather they should know that picture is being loaded,hence the delay.Pls suggest improvement in code.My code for loading picture in flipcard is:
public void setBMP(String s) //String passed is url extracted from column of db uing
{ //internal db
try{
//String url1 = "c.getString(3)";
String url1= s;
System.out.println(url1);
URL ulrn = new URL(url1);
HttpURLConnection con = (HttpURLConnection)ulrn.openConnection();
InputStream is = con.getInputStream();
Bitmap bmp = BitmapFactory.decodeStream(is);
if (null != bmp)
{
im.setImageBitmap(bmp);
}
else
System.out.println("The Bitmap is NULL");
}catch(Exception e){}
}
}
For changing view, i have set up actionListener.As soon as user touches screen card flips and image loads.
Also is it possible to preload the images in background while user is viewing some other card.Or is it possible to cache the cards viewed?
I would go the asnyctask route, because that way you can load/disable spinners (or wahtever loading animations) as well. Check out this answer for a really simple example. If you want to add spinners you need to start them in the onPreExecute() of the asnyctask (just add it to the example) and disable them in onPostExecute after you image is downloaded.
Using AsyncTask to load Images in ListView
it seems to me that creating a Runnable that gets the bmp and saves it to a hash map file and then, when it's needed if downloaded, it opens the file, and if not it downloads it from the web.
try looking at fedorvlasov's Lazy adapter for reference.
you can use his Image loader