I'm having issue of missing signout button from the header toolbar in android devices. In simulator and apple device I do see the signout button but not on android tablet/phone. This wasn't the case before 3-4 days. Is there any change in the android build server that causing this issue. This is happening when more than one control in the toolbar. if the toolbar has one control to the right then it displays without any issue. Please let me know if anyone else have same issue.
Android Simulator Screenshot
Android Tablet Screenshot
public static void addSignout(Form f) {
f.getToolbar().addMaterialCommandToRightBar("", FontImage.MATERIAL_LOCK, 6.5f, e -> {
Server.instance.logout();
new LoginForm().show();
});
}
Related
I am running the latest Xamarin Forms on VS 2019 community edition.
I just started the basic Xamarin Forms project and added a Flyout page template to it.
When running this on the Android emulator it works fine, but the menu won't close after selecting a page.
The code has not changed apart from adding another page to the menu items.
The code isPresented = false is still there but has no effect whatsover.
Is it simply not possible to have the menu collapse in landscape mode? Then what are my alternatives?
You just have to add in the MenuPage (the main file, the first one that is generated) the following property:
FlyoutLayoutBehavior = "Popover"
public MasterMenuItem ()
{
InitializeComponent ();
MasterBehavior = MasterBehavior.Popover; // This solve my problem
}
In a sample Xamarin.Forms application we are trying to focus an Entry field after it becomes Visible on a Button Click
Below is the code snippet we are using to achieve above behavior I mentioned
void OnClick(object sender,EventArgs arg)
{
searchEntry.IsVisible = true;
searchEntry.Focus();
}
This is working fine in all iOS devices and android devices below 9 for android 9 and 10 the keypad shows up but the typed letters are not getting reflected in the Entry fields.
Can anyone have experienced the same issue before? Please let me know if there is any solution for that in the Answers section.
Give device some time to process previous request.
(void)OnClick(object sender,EventArgs arg)
{
searchEntry.IsVisible = true;
await Task.Delay(500);
searchEntry.Focus();
}
Downloaded Xamarin Camera2Basic project
Initially all works correctly as it's begin tested in Visual Studio 2017 emulator.
Commented out code inside "CameraCaptureStillPictureSessionCallback.cs" as shown below to allow the still image captured to be displayed on the emulator screen after clicking the "Take Picture" button:
public override void OnCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result)
{
//Owner.ShowToast("Saved: " + Owner.mFile);
//Log.Debug(TAG, Owner.mFile.ToString());
//Owner.UnlockFocus();
}
Clicking the "Take Picture" button hides itself, and shows another button labeled "Retake Picture" on the screen (which I added after the fact and the code is located in the Camera2BasicFragment.cs file, but the code is inconsequential to the issue).
Clicking the now visible "Retake Picture" button does the following:
Hides itself
Shows the "Take Picture" button
Calls UnlockFocus()
UnlockFocus() allows the camera's stream to display continuously on the screen instead of the still image captured previously.
Now, when I click the "Take Picture" button again (to attempt to capture a new still image), the app crashes.
Visual studio does not provide any meaningful error messages. The closest useful bit of information are the error messages displayed int the Device Log:
07-26 23:29:03.201 10.1" Marshmallow (6.0.0) XHDPI Tablet Error 6987 BufferQueueProducer [ImageReader-640x480f100m2-6987-0] dequeueBuffer: can't dequeue multiple buffers without setting the buffer count
07-26 23:29:07.174 10.1" Marshmallow (6.0.0) XHDPI Tablet Error 6987 RequestThread-0 Hit timeout for jpeg callback!
07-26 23:29:03.201 10.1" Marshmallow (6.0.0) XHDPI Tablet Error 6987 Legacy-CameraDevice-JNI LegacyCameraDevice_nativeProduceFrame: Error while producing frame Function not implemented (-38).
I'm not sure what to make of these errors, or which settings/code to change to allow the "Retake Picture" functionality to work without crashing the app.
Any suggestions?
EDIT 1:
Per request, where is a link to the project as I currently have it.
https://drive.google.com/file/d/0B7OSuA_ybXcFb081T210UlQzZkE/view?usp=sharing
Here is some other seemingly pertinent information:
This code was run using:
a. Windows 10 Pro, Visual Studio 2017 Community, Android Emulator
For Visual Studio, Hyper-v Virtual Manager, Android 6.0
(Marshamallow SDK 23), Tablet sized template
b. 2013 Macbook Pro, Visual Studio For Mac (latest version), default
emaulator, Android 6.0 (Marshmallow SDK 23), Tablet sized template.
The failure to take snapshot after second "LockFocus" call is observed in both environments.
The Mac made it easier to find some more meaninful errors:
a. The error I saw happened on method "produceFrame" inside
LegacyCameraDevice.java
I've the problem with this demo also, The real problem behind this is about the IOnImageAvailableListener, it will not trigger the OnImageAvailable method to save the picture...
After read the code, i found out that the demo is broken, it missing some piece.
In the Camera2BasicFragment.cs, in the OnCreateMethod, you will need to add this line
mCaptureCallback = new CameraCaptureListener() { Owner = this};
The entire method should look like this:
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
mStateCallback = new CameraStateListener() { owner = this };
mSurfaceTextureListener = new Camera2BasicSurfaceTextureListener(this);
// fill ORIENTATIONS list
ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);
}
The interesting thing is, if you run this on emulator, nothing will happened, because in the CameraCaptureListener.cs file, this will always return 0, not ControlAFState.FocusedLocked or ControlAFState.InActivate
Integer afState = (Integer)result.Get(CaptureResult.ControlAfState);
Event if i hack the If method to be able to run jump into next step, the method OnImageAvaiable of ImageAvailableListener.cs will never be triggered by emulator. But if i run on the real device, it ran fine ?!
So the fix is:
1. Add the code above like i explained on the onCreate function.
2. Don't use emulator to run Camera2, it's buggy.
Hope it help :)
If you are still interested; IOnImageAvailableListener not trigger OnImageAvailable method in Visual Studio Emulator For Android.
Code is correct but Visual Studio Emulator For Android have a bug. I hope they fix it as soon as possible. On the other hand you can try your code in Xamarin by using Android Studio Emulator without any bug. It is easy and you dont need to know anything about Java or Android Studio Just follow the below steps
Install Android Studio with virtual device
Close Hper-v on your pc (windows -> control panel -> programs -> programs and features -> Turn windows features on or off)
Open android studio -> Tools -> Avd Manager -> Create Virtual Device
Visual studio detect the virtual device just use it on Visual Studio Xamarin
hope it help
I'm using Xamarin Forms to produce a TabbedPage consisting of more ContentPages. This is the part of code causing trouble:
public void launchMainDesign(object s, EventArgs e) {
MainPage = new TabbedPage {
Children = {
new ContentPage {
Title = "Login",
Content = pages.loginContent,
BackgroundImage = "bgmain.jpg"
},
new ContentPage {
Title = "Sign Up",
Content = pages.signUpContent,
BackgroundImage = "bgmain.jpg"
}
}
};
}
It seems absolutely fine. I have both the images in my Drawable directory, with the build action set to "AndroidResource".
Whenever the launchMainDesign() function is fired by pressing a button, the app crashes immediately, both in emulator and a build version of the app on a tablet. Unfortunately, I can't test on iOS and WP.
I even tried putting the whole inside part of the function in a try/catch block and print out the exception, but the app just crashes nevertheless.
I am desperately trying to solve this simple problem for about a week now. No one seems to be having exactly the same issue as me. Weirdest thing is, I have a different app where I use exactly the same method and it works just fine. Can the Android Theme be causing this (I'm using Holo, in the working app, there's no theme specified)? That seems to be the only difference.
I also don't think this is caused by RAM struggles, as the image is only about 700 kilobytes (1080x1920) - for this example, I've only used one image.
It could be a memory issue, because even do the size is not big depending on the device resolution it might be trying to scale the image to the device dimensions.
Try checking this README:
https://github.com/xamarin/customer-success/blob/master/samples/Xamarin.Forms/SliderView/README.md
Explains Xamarin.Forms Android Image Memory Management so could help you get around the issue you might be having.
I´m experiencing a weird problem with SlidingMenu Library and ViewPager when they are running on devices with Android 3.2 (Honeycomb).
The problem appears when we "toggle" the SlidingMenu to show the Menu that is hidden on the left of the app. When we do this, both ContentView and BehingContentView stops responding to touch events.
Thinking that this was a problem related to my application, I downloaded the last version of ABS and SlidingMenu library and configured a new project using the built-in example that comes with the SlidingMenu and, for my surprise, the same behavior occurred with the ViewPager example.
These are the steps that I did:
Configure an Emulator using API Level 13 and 7" WSVGA (Tablet);
Download ABS and SlidingMenu from GIT;
Setup a new Project, using the compatibility library android-support-v41 (Also tested with android-support-v4);
Solved the problem 'getSupportActionBar() is undefined' as described here: https://github.com/jfeinstein10/SlidingMenu/issues/145;
Run the 'Example Application' and choose 'ViewPager' example;
Swipe pages to the right and to the left, without opening the menu;
Open the menu. See that the lists don´t scroll as expected;
Close the menu. See that the viewpager doesn´t responds to touch events anymore;
Notice that this behavior was reported only on Android 3.2 devices. We have the same application running on 2.x and on 4.x devices, without this problem.
Also, noticed that the Example Application that was downloaded from Google Play doesn´t have this problem.
Does anybody have any advice? Thanks a lot!
Edit 1
Tested on a real device, and confirmed the Behavior. Does anybody have an advice?
I had the same problem and fixed it by using the following work-around.
Replace these lines in SlidingMenu.java:
#TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void manageLayers(float percentOpen) {
if (Build.VERSION.SDK_INT < 11) return;
with:
#TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void manageLayers(float percentOpen) {
if (Build.VERSION.SDK_INT < 14) return;