Windows Phone 8 - take a screenshot - windows-phone

Is there any way to take a screenshot on Windows Phone 8 (or 7.1) programmatically?
For Windows Phone 7/7.1, there is at least an inofficial solution:
http://forum.xda-developers.com/showthread.php?t=1006331
But I have no idea what to do to get this functionality in my own app.
Also, I would intend to take screenshots not only of my own app but also of other apps (e.g. timer triggered).

you can take the screen shot in your windows phone 8, by the simultaneous press of the volume button and the window key. or else try this code
var bmp = new WriteableBitmap(lbxDays, new TranslateTransform());
var width = (int)bmp.PixelWidth;
var height = (int)bmp.PixelHeight;
bmp.Render(lbxDays, new TranslateTransform());
using (var ms = new MemoryStream())
{
bmp.SaveJpeg(ms, width, height, 0, 100);
ms.Seek(0, System.IO.SeekOrigin.Begin);
var lib = new MediaLibrary();
var dateStr = DateTime.Now.Ticks;
var picture = lib.SavePicture(string.Format("screenshot"+dateStr+".jpg"), ms);
var task = new ShareMediaTask();
task.FilePath = picture.GetPath();
task.Show();
}

You could easily do this on emulator, run your app, and then click double arrow button which pops up another window, and then go to screenshot tab and capture. Or if you have device press Widnows Home and Power simmontaniously.

You can take a screenshot using your Emulator.
When you run your app on Emulator you can see a double arrow button
right side of the Emulator.
Click on that double arrow button, which ll show another window right
side of the Emulator.
And Tap on the screenshot tab and capture the screenshot.
You can save the screenshot to your local machine.

Related

Selenium IDE isn't working with canvas

I'm using canvas (phaser.io game framework) to make games and would like to do selenium tests. Sadly I can't replay recorded actions on a canvas.
For example I can't replay the click on the button here https://phaser.io/examples/v2/input/button-open-popup
I get this in the log:
1.Trying to execute open on /examples/v2/input/button-open-popup... Success
2.Trying to execute selectFrame on index=0... Success
3.Trying to execute clickAt on css=canvas with value 422,502... Success
But nothing happens on the screen and the popup is not poping up.
Is there a problem with clicking on canvas through Selenium IDE or maybe I'm doing something wrong?
I did some automated tests for Phaser games.
Let's take an example, I have to click on a menu button.
The way I managed to click on the button precisely every time is that I created a html page, with the same width and height as my canvas ( first, I decided the size of the chrome window, for me I used 800x900, and then get the canvas size), and in my html page I only put javascript to output me the positions where I click.
So basically I created a html, with the same dimension as my canvas, and clicked on it at the approximate position of my canvas button.
Here is the code I've used for my tests:
var mainState ={
preload: function(){
},
create: function(){
game.stage.backgroundColor = '#71c5cf';
game.scale.pageAlignHorizontally = true;
game.scale.pageAlignVertically = true;
},
update: function(){
getcoordinates();
}
};
function getcoordinates(){
if (game.input.mousePointer.isDown){
var x = game.input.activePointer.position.x;
var y = game.input.activePointer.position.y;
console.log("x" + x, "y" + y);
var worldx = game.world.centerX;
var worldy = game.world.centerY;
console.log("world x" + worldx, "world y"+ worldy);
}
};
var game = new Phaser.Game(384,683, Phaser.CANVAS);
game.state.add('mainState', mainState);
game.state.start('mainState');
As for checking if my action was succesfull, I used JavascriptExecutor. And in Selenium I've created some functions that do just that, navigate to coordinates and execute click.

How to scroll in mobile browser using Appium and selenium?

How to scroll in mobile browser using Appium and selenium? Scroll is working in app but not in browser. Using scrollToExact method. web app was developed using ionic framework
There several ways how to get it done.
If you are using instance of AppiumDriver, you need to switch to native view before you can use TouchAction
driver.context("NATIVE_APP");
// Get your screen size to set properly start point (startX, startY)
// and end point (endX, endY) for scrolling
Dimension screenSize = driver.manage().window().getSize();
new TouchAction(driver)
.press(<startX>, <startY>)
.waitAction(500)
.press(<endX>, <endY>)
.release()
.perform();
If you are using instance of RemoteWebDriver, then you can do it like this:
driver.get("https://www.google.de");
ExecuteMethod method = new RemoteExecuteMethod(driver);
RemoteTouchScreen screen = new RemoteTouchScreen(method);
screen.up(10, 20);
Thanks to dmle I discovered you need to switch to native view before you can use TouchAction. Anyway that code didn't work as press method doesn't accept two int values.
Here I share the code that worked in my case, and also how to use a web context element as a reference by saving its values before changing to native context. I do also restore the previous context:
//Get web context element references to touch on its area
MobileElement tmpElement = driver.findElement(by);
int x=tmpElement.getLocation().x;
int y=tmpElement.getLocation().y;
Dimension elemSize = tmpElement.getSize();
int height=elemSize.height;
//Save precious context
String previousContext=driver.getContext();
//Set native context
driver.context("NATIVE_APP");
//Perform scroll
new TouchAction(driver)
.press(ElementOption.point(x+5, y+height-5))
.waitAction(WaitOptions.waitOptions(ofSeconds(1)))
.moveTo(ElementOption.point(x+5, y+5))
.release()
.perform();
//Restore context
driver.context(previousContext);

Open Camera app installed from a UWP app and capture image

Instead of creating a Windows built-in camera UI (CameraCaptureUI) or using a custom MediaCapture control and capture picture I want to open any Camera App downloaded in the device to capture an image and get the result.
I have used
string uriToLaunch = "microsoft.windows.camera:";
var uri = new Uri(uriToLaunch);
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
But this just opens the camera app, I need to get the result file back to the app and save it.
Is there a way to do this?
The method you are using:
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
just opens the default camera, nothing more, the result is a boolean with information if the application has been opened successfully, nothing more.
With CameraCaptureUI you don't need to create camera - this seems to be designed for the task like you have described. With lines:
var captureUI = new CameraCaptureUI();
captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;
captureUI.PhotoSettings.CroppedSizeInPixels = new Size(200, 200);
var photo = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo);
you just launch the camera app and your app waits for the photo, which you can process further/save.
If you don't want to use it or implement own camera capture, you can think of sharing a picture taken by other app. This is described well at app-to-app communication at MSDN. In this case user will have to click Share button and choose your app as a target. That will invoke OnShareTargetActivated event where you can process the received content.

Titanium Appcelerator Video Player Back Button on Android

I am new to Titanium App Development. I am making a title list of videos using a ListView. When I click on an item, the specific video plays fine. However when I press the back button in Android, the application exits instead of going back to the previous list of videos. I have tried android:back and androidback event of the window but still the same. How should I fix this??? By the way I am using the Alloy Framework in Titanium
index.js
videos.fetch({query: 'select * from '+ videos.config.adapter.collection_name + ' where video_id = '+ vid_id});
var args;
for (var vd=0 ; vd < videos.length; vd++){
var e = JSON.parse(JSON.stringify(videos.at(vd)));
args = {
parent_id : lsn_sub,
video_data : e.video_data
};
console.log(args.video_data);
var mediaview = Alloy.createController("media", args).getView();
mediaview.open();
media.js
var parent_view = args.parent_id;
var vid_media = args.video_data;
console.log("parent source: "+parent_view);
console.log($.vid_media.url);
$.vid_media.url = vid_media ;
$.media.addEventListener('androidback', function(e){
alert("android back");
});
views/media.xml
<Alloy>
<Window class="container">
<VideoPlayer id="vid_media" ns="Ti.Media" ></VideoPlayer>
</Window>
The back button exits the application, not going back to previous screen.
Set the model property of your second window true.
<SecondWindow class="container" modal="true"></SecondWindow>
Also set modal and exitOnClose true on your first window if you want to close the app when user press android back on your first screen.
<FirstWindow class="container" modal="true" exitOnClose></FirstWindow >
there is no to add android:back event for it.
Hope this will help you
Thank you for the great help #suraj and #victor, but I figured it out already.
The reason for it to be not working is because I was testing it only in the simulator, not on a real device. When I run it on the real device, the 'back button' of the android actually works fine. It stops my video and goes back to the previous screen.
We should really test on a real device rather than relying on a simulator. Have a great day! :)
Another possible solution
is to cancel the bubbling effect of the androidback event,
$.media.addEventListener('androidback', function(e) {
e.cancelBubble = true;
[...Your logic here...]
}

Change the tile image of a shortcut tile pinned on the metro desktop

we have created a tile shortcut, which is similar to pinning the IE shortcuts on the screen. We have done this through code. We want an image should come on this tile. How do we add image to such a shortcut tile. we are running an exe first on windows 7 desktop mode and then making the pin to screen event click using the shell scripting. the tile is similar to any internet address pinned on the desktop
See this sample app...
The basic code you will need to achieve this is as follows...
Uri logo = new Uri("ms-appx:///Assets/squareTile-sdk.png");
Uri smallLogo = new Uri("ms-appx:///Assets/smallTile-sdk.png");
string tileActivationArguments = MainPage.logoSecondaryTileId + " WasPinnedAt=" + DateTime.Now.ToLocalTime().ToString();
SecondaryTile secondaryTile = new SecondaryTile(MainPage.logoSecondaryTileId,
"Title text shown on the tile",
"Name of the tile the user sees when searching for the tile",
tileActivationArguments,
TileOptions.ShowNameOnLogo,
logo);
secondaryTile.ForegroundText = ForegroundText.Dark;
secondaryTile.SmallLogo = smallLogo;
bool isPinned = await await secondaryTile.RequestCreateAsync();