Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 89864 articles
Browse latest View live

"java.io.IOException: cannot create document. Error: 3" using Xam.Plugin.PdfRasterizer

$
0
0

I'm using the Xam.Plugin.PdfRasterizer to convert a pdf file into an image and I'm getting following error:

java.io.IOException: cannot create document. Error: 3
    at android.graphics.pdf.PdfRenderer.nativeCreate(Native Method)
    at android.graphics.pdf.PdfRenderer.<init>(PdfRenderer.java:157)

My code:

var fileData = await CrossFilePicker.Current.PickFile();
var savedFile = await FileSystem.Current.LocalStorage.CreateFileAsync(fileData.FileName, CreationCollisionOption.ReplaceExisting);
var document = await CrossPdfRasterizer.Current.RasterizeAsync(savedFile.Path, false);

What's wrong with my code?
When I'm using a public pdf path, it works. It's just when I'm picking a file from the local storage..

Thanks for your help!


How to change the name of app(In the screen, under the icon)

$
0
0

Hi guys,

I am building an app in Xamarin.Forms. I want to change the name of app, both iOS and Android. I tried to change the information in mainactivity.cs and Androidmanifest. However it is not working. I also don't know how to do it in iOS.

Would you please to help me?

Thank you very much.

Image Size AspectFit to fill parent StackLayout

$
0
0

Hi all - I'm having difficulty with what seems like a basic issue. I have an image that I want to fit within a stacklayout whilst keeping the aspect ratio intact. Normally, I would utilise AspectFit and all would be dandy.... however, on this project, no such luck. My guess it is possibly due to the combination of ralativelayout (to provide a background image) and grids (to display the content in the top 80%, image in the bottom 20%.

Binding ImageSource is a random group of misfit images... not all the same measurements. The result I am getting is portrait images displaying at fullsize (where I want them to be scaled down to fit). Landscape images work ok. I have tried using the HeightRequest parameter, but I am finding that on high res phones, the image is tiny.

Any ideas on how to fix, or what might be causing this behaviour?

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="NationsConnect.View.CategoryView"
             Title="{Binding PageTitle}">

    <ContentPage.Content>

        <RelativeLayout VerticalOptions="Fill" HorizontalOptions="Fill">

            <Image Source="nations_connect_logo.png" Opacity="0.1" 
                   RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
                   RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height}"/>

            <Grid x:Name="serviceCategories" VerticalOptions="FillAndExpand" 
                  RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
                  RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height}">

                <Grid.RowDefinitions>
                    <RowDefinition Height="80*" />
                    <RowDefinition Height="20*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <StackLayout Orientation="Vertical" HorizontalOptions="CenterAndExpand" Grid.Row="0" Grid.Column="0"  >
                    <ListView VerticalOptions="StartAndExpand" ItemsSource="{Binding Categories}" SelectedItem="{Binding SelectedCategory, Mode=TwoWay}" >

                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                    <Grid>
                                        <StackLayout VerticalOptions="Center">
                                            <Label Text="{Binding category_name}" />
                                        </StackLayout>
                                    </Grid>
                                </ViewCell>
                            </DataTemplate>
                        </ListView.ItemTemplate>

                    </ListView>
                </StackLayout>

                <StackLayout Orientation="Vertical" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Grid.Row="1" Grid.Column="0" >
                    <Image Source="{Binding ImageSource}" Aspect="AspectFit" />
                    <Image.GestureRecognizers>
                        <TapGestureRecognizer Command="{Binding TapImageCommand}" CommandParameter="{Binding ImageId}" />
                    </Image.GestureRecognizers>
                </StackLayout>

            </Grid>

        </RelativeLayout>
    </ContentPage.Content>
</ContentPage>

File picker with multiple file selection

Entry with numeric keyboard changing app background color

$
0
0

I'm noticing very odd behavior on Android using Xamarin.Forms. Typing into an Entry with a numeric keyboard darkens the background color. This behavior occurs even on a clean project with nothing but an Entry:

using Xamarin.Forms;

namespace App1
{
    public class App : Application
    {
        public App()
        {
            MainPage = new MainPage();
        }
    }

    public class MainPage : ContentPage
    {
        public MainPage()
        {
            Content = new Entry { Keyboard = Keyboard.Numeric };
        }
    }
}

When the Entry is first focused into, nothing unusual happens. In fact, if you click the tick at the bottom right of the keyboard to close it without entering anything, nothing happens either. But if you type anything (even if you backspace it), the background color of the app changes. It even affects other pages in a navigation stack.

What is the cause of this can how can it be fixed?

Can you have dynamic cell heights with either the ListView or TableView views?

$
0
0

Can you have dynamic cell heights with either the ListView or TableView views?

SQLite.Net.Platform.XamarinAndroidN 3.1.1

$
0
0

hello

please iam trying install SQLite.Net.Platform.XamarinAndroidN on xamarin.forms i can not install (restored failed) all time until on fresh xamarin project .

Package SQLite.Net.Platform.XamarinAndroidN 3.1.1 is not compatible with monoandroid80

any solution for this

Xamarin Outside of Visual Studio

$
0
0

Just curious, is it possible to run Xamarin outside of Visual Studio? Me and Visual Studio just don't get along....and I'm afraid the time has come for one of us to go.

If the answer is no, then what other cross-platform solutions have you used and how do they compare?


How do I resolve MT0117 Error? (Can't launch a 32-bit app)

$
0
0

I'm going through the blog on CarouselView for Xamarin.Forms. I'm running into this error:
Launch failed. The app 'Monkeys.iOS' could not be launched on 'iPhone 8 Plus iOS 11.2'. Error: error MT0117: Can't launch a 32-bit app on a simulator that only supports 64-bit apps (iPhone 8 Plus).

How do I get past this so I can launch the app on iOS Simulator?

reopen Application after Taking Picture from Plugin.Media sending my application into background.

$
0
0

HI
I am new in Xamarin.forms i am using xam.Plugin.Media.
While i am taking picture from the phone or choosing picture from gallery , My Application going into background.
how to overcome with this problem.

ForceUpdateSize slows UI

$
0
0

Hi!

I have this strange issue, i have a ViewCell inside a ListView that expands when you tap inside, calling cell.ForceUpdateSize() , this works OK, but if you it repeated times (say, like 3 or 4 times) it starts to get slower every time, until it stops working (freezes)

 void Cell_OnTapped(object sender)
        {
            var cell = sender as InventoryCell;
            cell.Height = cell.Height == 40 ? cell.Height + 30 : cell.Height = 40;
            cell.ForceUpdateSize();

        }

Any info about it?... btw, using XF on iOS

visual studio bug

$
0
0

hello, i'm new to coding and don't have any experience but i just installed visual studio installed the sdk/ndk and created a device. I clicked file/new/c#/android/blank app and when I created the project and open main.axml I have an error on the bottom. I reinstalled windows and looked up my issue but couldn't find this anywhere. here are some screenshots (keep in mind like i said this is a brand new project i didn't even type one line of code in and i also reset windows)

since I just made this account I'm not allowed to post links so you're gonna have to stitch this for screenshots, sorry!

imgur . com/a/83faq

"This project contains resources that were not compiled successfully rendering might be affected"

Main.axml error: This project contains resources that were not compiled succesfully, rendering might

$
0
0

I just installed Xamarin (Visual Studio). But I have a problem: When I start a new Android project (Blank app) and I open the Main.axml there is this message: "This project contains resources that were not compiled succesfully, rendering might be affected"

Maybe it's easy to solve, but I can't find what the solution is. Is there anyone who can help me?

Thank you very much.

NullReferenceException on InitializeComponents - What did I do wrong?

$
0
0

Hello,

I've encountered an error when loading a new ContentPage. When the app reaches InitializeComponents() I'm thrown with System.NullReferenceException. (both on iOS and Android)

Can someone please explain what I did wrong here?

Here's the code and stack trace: (I used PasteBin because they're long)
SettingsPage.xaml
SettingsPage.xaml.cs
Stack Trace

Thanks in advance for any help!

Xamarin.Forms.MVVMLight


get current location Xam.Plugin.Geolocator

$
0
0

i use Xam.Plugin.Geolocator, i did the same as the documentation, and it work find in android emulator, but when i deploy it to my mobile,
i got this exception:

{System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Plugin.Geolocator.FusedGeolocatorImplementation+d__32.MoveNext () [0x00450] in C:\projects\geolocatorplugin\src\Geolocator.Plugin.Android\FusedGeolocatorImplementation.cs:221
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at RealShopOnline.Views.SecondPageVolumes+d__5.MoveNext () [0x00077] in E:\MyLovelyApps\RealMobileApp\RealShopOnline\RealShopOnline\RealShopOnline\Views\SecondPageVolumes.cs:166 }

any help?

Blurred ContentView

$
0
0

I need a content view that blurs whatever is below it so I thought I'd try writing a custom control and an iOS renderer for it. This is the class definition ...

public class XBlurredContentView : ContentView
{
}

... here's the custom renderer ...

public class XBlurFrameRenderer : ViewRenderer<XBlurredContentView,UIView>
{
    private UIVisualEffectView _effectView;

    protected override void OnElementChanged(ElementChangedEventArgs<XBlurredContentView> e)
    {
        base.OnElementChanged(e);
        var blurFrame = e.NewElement;
        if (blurFrame != null)
        {
            var effect = UIBlurEffect.FromStyle(UIBlurEffectStyle.Light);
            _effectView = new UIVisualEffectView(effect);
            SetNativeControl(_effectView);
        }
    }

    protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        if (e.PropertyName == VisualElement.XProperty.PropertyName
            || e.PropertyName == VisualElement.YProperty.PropertyName
            || e.PropertyName == VisualElement.HeightProperty.PropertyName
            || e.PropertyName == VisualElement.WidthProperty.PropertyName)
        {
            var x = Element.X; var y = Element.Y; var w = Element.Width; var h = Element.Height;
            _effectView.Frame = new CGRect(x, y, w, h);
        }
        base.OnElementPropertyChanged(sender, e);
    }
}

... and here's the XAML to test it ...

    <customUi:XBlurredContentView HeightRequest="50">
        <Grid>
            <Button Text="Hello World" TextColor="White" />
        </Grid>
    </customUi:XBlurredContentView>

The expected are does get blurred as expected but the content (the "Hello World" button isn't visible. I double checked with the Live Inspector and it does look like the button (and it's UILabel) is added correctly but nothing is visible on screen. This is my first go at deriving the ContentView into a custom control so I guess I need to learn more but what have I missed?

How to upload image to server from xamarin forms app?

$
0
0

I'm trying to send an image from my xamarin forms application to a asp .net core server using a post request. I need to save the image in some server folder but I can not do it.

This is the method to send the image once I have it selected in _mediaFile

    private async void UploadFile_Clicked(object sender, EventArgs e)
    {
        var uri = new Uri(string.Format(Constants.UsersRestUrl + "/Files/Upload/", string.Empty));
        var content = new MultipartFormDataContent();

        content.Add(new StreamContent(_mediaFile.GetStream()),
            "\"file\"",
            $"\"{_mediaFile.Path}\"");

        var httpClient = new HttpClient();
        var httpResponseMessage = await httpClient.PostAsync(uri, content);
    }

I currently have this in my api controller

[Route("Files/Upload/")]
[HttpPost]
public async Task<IActionResult> Post(IFormFile file)
{
    Debug.Write("******");
    // full path to file in temp location
    var filePath = Path.GetTempFileName();
    Debug.Write("****** File Path " + filePath);

    if (file.Length > 0)
    {
        using (var stream = new FileStream(filePath, FileMode.Create))
        {
            await file.CopyToAsync(stream);
        }
    }
    return Ok(new { file });
}

Can someone help me? Thanks

how to share resources between 2 android projects?

$
0
0

I want to have 2 android projects in my solution. 1 for google another for amazon store. 2 projects have same resources and mostly other classes. what is the best project type to share those? I tried using android class library but it doesnt work. i am getting different errors although I installed support libraries. can somebody shed some lights on me please?

incompatibility between HAXM hypervisor and VirtualBox 4.3.30+

$
0
0

Having an issue with the emulator deploying an app. I keep getting an issue that "there's an incompatibility between HAXM hypervisor and VirtualBox 4.3.30+ which doesn't allow multiple hypervisors to co-exist.".

I am running a newly purchased windows machine and never have installed virtual box.

Have attached screen shots of setup... anyone else run into this issue as I cant make sense of this at the moment.

2>Starting deploy Emulator_Nexus_5 ...
2>Starting emulator Emulator_Nexus_5 ...
2>C:\PROGRA~2\Android\ANDROI~1\tools\emulator.EXE -partition-size 512 -no-boot-anim -avd Emulator_Nexus_5 -prop monodroid.avdname=Emulator_Nexus_5
2>Hax is enabled
2>Hax ram_size 0x40000000
2>HAX is working and emulator runs in fast virt mode.
2>audio: Failed to create voice `goldfish_audio_in'
2>qemu-system-i386.exe: warning: opening audio input failed
2>emulator: Listening for console connections on port: 5554
2>Failed to sync vcpu reg
2>emulator: Serial number of this emulator (for ADB): emulator-5554
2>Failed to sync vcpu reg
2>Failed to sync vcpu regemulator: ERROR: Unfortunately, there's an incompatibility between HAXM hypervisor and VirtualBox 4.3.30+ which doesn't allow multiple hypervisors to co-exist.  It is being actively worked on; you can find out more about the issue at http://b.android.com/197915 (Android) and https://www.virtualbox.org/ticket/14294 (VirtualBox)
2>
2>Internal error: initial hax sync failed
2>Emulator Emulator_Nexus_5 cannot be started.
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

Viewing all 89864 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>