Android PrintHelper Orientation - android

I am using PrintHelper API provided by android 19 and above for wireless printing, using following code which is supposed to set preview to landscape according to code but actually its showing preview in portrait mode. Any help would be appreciated
Please refer Android code used for printing below
PrintHelper printHelper = new PrintHelper(context);
printHelper.setOrientation(PrintHelper.ORIENTATION_LANDSCAPE);
printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
printHelper.setColorMode(PrintHelper.COLOR_MODE_MONOCHROME);
printHelper.printBitmap("testPrint", bitmap);

Related

PrintAttributes not working. not able to create custom page size

I am struggling with google printing interface in tablet. I want a print of fixed page size. PrintAttributes.Builder is not modifying the page and margin settings. How can i create a new custom/fixed page dimension for print. Now It shows ISO_A4 by default for HP printer.
My code is below:
PrintAttributes.Builder builder = new PrintAttributes.Builder();
PrintAttributes.MediaSize custom = new PrintAttributes.MediaSize("VISIT_K" , "VISIT_K", 86000,139860);
custom.asPortrait();
builder.setMediaSize( custom );
printJob = printManager.print(jobName, adapter,
builder.build());
Which Android version are you testing on? See this answer concerning a bug pre- Android 7
Regardless, the attributes here serve only as "hints", from the Android documentation:
You can use this parameter to provide hints to the printing framework
and pre-set options based on the previous printing cycle, thereby
improving the user experience. You may also use this parameter to set
options that are more appropriate to the content being printed, such
as setting the orientation to landscape when printing a photo that is
in that orientation.
I think if it conflicts with what the printer is reporting as supported/default, the printer's attributes may take precedence. This could be a feature/bug report to Android if it is not otherwise working.

Taking Screenshots Using Qt C++ on Android

thanks for checking my question out!
I'm currently working on a project using Qt C++, which is designed to be multi-platform. I'm a bit of a newcoming to it, so I've been asked to set up the ability to take screenshots from within the menu structure, and I'm having issues with the Android version of the companion app.
As a quick overview, it's a bit of software that send the content of a host PC's screen to our app, and I've been able to take screenshots on the Windows version just fine, using QScreen and QPixmap, like so:
overlaywindow.cpp
{
QPixmap screenSnapData = screenGrab->currentBackground();
}
screenGrabber.cpp
{
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( QApplication::desktop()->winId() );
}
Unfortunately, Android seems to reject QScreen, and with most suggestions from past Google searches suggesting the now-deprecated QPixmap::grab(), I've gotten a little stuck.
What luck I have had is within the code for the menu itself, and QWidget, but that isn't without issue, of course!
QFile doubleCheckFile("/storage/emulated/0/Pictures/Testing/checking.png");
doubleCheckFile.open(QIODevice::ReadWrite);
QPixmap checkingPixmap = QWidget::grab();
checkingPixmap.save(&doubleCheckFile);
doubleCheckFile.close();
This code does take a screenshot, but only of the button strip currently implemented, and not for the whole screen. I've also taken a 'screenshot' of just a white box with the screen's dimensions by using:
QDesktopWidget dw;
QWidget *screen=dw.screen();
QPixmap checkingPixmap = screen->grab();
Would anyone know of whether there was an alternative to using QScreen to take a screenshot in Android, or whether there's a specific way to get it working as compared to Windows? Or would QWidget be the right track? Any help's greatly appreciated!
as i can read in Qt doc : In your screenGrabber.cpp :
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( QApplication::desktop()->winId() );
replace with :
QScreen *screen = QGuiApplication::primaryScreen();
return screen->grabWindow( 0 ); // as 0 is the id of main screen
If you want to take a screenshot of your own widget, you can use the method QWidget::render (Qt Doc):
QPixmap pixmap(widget->size());
widget->render(&pixmap);
If you want to take a screenshot of another app/widget than your app, you should use the Android API...

Unity3D Webcam Autofocus Callback?

I want to take a picture from camera using Unity. Taking picture itself is not a big deal but I want more accurate one using autofocus callback method like in Android (onAutoFocus(boolean success, Camera camera)) So I can take a picture if callback returns success true. Is there any way to do it in Unity or I need some plugin for that? If there is one can somebody reference to it? Thanks a lot!
There is a plugin called Camera Capture Kit available on the assetstore that seems to be able to do what you want. We used the code to make theese features available on both Android as well as iPhone.
https://www.assetstore.unity3d.com/en/#!/content/56673
Camera Capture Kit comes with a plug-n-play camera app which enables Auto-focus - you can set the autofocus mode by calling .
CameraCapture.UnitySetFocusMode( webCamTextureReferance, FocusModes.Autofocus );
That will represent AVCaptureFocusModeAutoFocus and you should be able to trigger a callback for the focus event yourself by adding a piece of code like this in the function initCapture in the file Assets/Tastybits/Native/iOS/CameraCapture.mm :
[camDevice addObserver:self forKeyPath:#"adjustingFocus" options:flags context:nil];
Now, Camera Capture Kit doesn't give you a callback when focus is being done on iOS so you will have to add it yourself and calling back to unity yourself using SendMessage.
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if( [keyPath isEqualToString:#"adjustingFocus"] ){
BOOL adjustingFocus = [ [change objectForKey:NSKeyValueChangeNewKey] isEqualToNumber:[NSNumber numberWithInt:1] ];
NSLog(#"Is adjusting focus? %#", adjustingFocus ? #"YES" : #"NO" );
if(adjustingFocus)
UnitySendMessage( "FocusController", "FocusChanged", "1" );
else
UnitySendMessage( "FocusController", "FocusChanged", "0" );
}}

Fullscreen on an Android device with objects off stage

I'm trying to put an AS3 "Flappy bird" example on my Android device but I can't put it in fullscreen and I don't understand why..
On the Adobe Flash pro emulator, the game is in fullScreen mode :
Image1
But on my Android device it's like that :
Image2
I think it is because I've got objects off stage...
Do you know, how can I put the game on fullscreen mode on my Android device ?
Thank you,
I've tried :
public function Main() {
stage.stageWidth=Capabilities.screenResolutionX;
stage.stageHeight=Capabilities.screenResolutionY;
stage.displayState = StageDisplayState.FULL_SCREEN;
stage.scaleMode = StageScaleMode.EXACT_FIT;
trace("fullscreen");
}
But still not working....
In your app.xml file for this project do you see <fullScreen>true</fullScreen> after <initialWindow> If not, write it in, exactly as shown, and publish to your Android device using ADT.
On mobile devices, "fullscreen" refers to whether or not the black status bar shows.
Set your swf to display without any scaling:
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;

fullScreenSourceRect not working in Adobe Air Android app

Simplest possible example, a new .fla, targeting AIR 3.8 for android, stage sized 1600x900, with the following AS3 on the first frame:
import flash.geom.Rectangle;
import flash.display.StageDisplayState;
import flash.display.Shape;
var rect:Shape = new Shape();
rect.graphics.beginFill(0x00ff00);
rect.graphics.drawRect(0,0,640,480);
addChild(rect);
stage.displayState = StageDisplayState.FULL_SCREEN;
stage.fullScreenSourceRect = new Rectangle(rect.x,rect.y,rect.width,rect.height);
I would expect the device to 'zoom' to show only the green rectangle - that's how the exact same code works when compiled for windows rather than android - but instead, I just get the normal view of the stage, with the rectangle up in the corner.
what am I missing?
From the docs
The fullScreenSourceRect property can only be set when Flash Player or AIR is not in full-screen mode. To use this property correctly, set this property first, then set the displayState property to full-screen mode.
Are you setting FULL_SCREEN first as in your example?

Categories

Resources