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

app is terminated after launching(xamarin.ios)app

$
0
0

app is terminated after launching(xamarin.ios)app
Launch failed. The app 'App1.iOS' could not be launched on 'iPhone'. Error: error MT1007: Failed to launch the application '/Users/dsgs/Library/Caches/Xamarin/mtbs/builds/App1.iOS/ab70f97c9774c4c76b94c0296ebef022/bin/iPhone/Debug/App1.iOS.app' on the device 'iPhone': Failed to launch the application 'com.yourcompany.App1' on the device 'iPhone': Invalid Service Error (error: 0xe8000022). You can still launch the application manually by tapping on it.


Newtonsoft.Json error

$
0
0

hi guys, i'm trying my app in my phone but if i try the app with Wi-Fi the app work well, if i try the app with my mobile internet connection it don't work.
Here is my code:
var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(20) };
HttpResponseMessage response = await client.GetAsync("http://unthreaded-storm.000webhostapp.com/Connession.php?Query=Select Username, aes_decrypt(Password,'LpOkzQA8IapOc4GJk2CHjM9wjIM') as Password From User");
var result = await response.Content.ReadAsStringAsync();
var dataSet = JsonConvert.DeserializeObject(result);
int u = 0;
int p = 0;
foreach (var datatable in dataSet.posts)
{
//My code
}

Thanks to all for the help

Dedicated Barcode Scanners in Xamarin Forms

$
0
0

I have been looking for a solution to use dedicated barcode scanners (so, NO camera scanning) connected either through bluetooth or USB (to a docking station) with an Android, iOS (maybe also UWP) tablet or phone device. And to my deep disappointment, it appears impossible to find information that is helping. Most suggestions talk about supporting Android, others about using ZXing library which uses camera to scan meaning it is dead slow to do scanning that way as camera needs to be loaded, then to focus on a barcode in order to scan it. That sometimes takes seconds.

ZXing might be great for individual users, regular phone/tablet user scanning only once in a while. Camera scanning is great that way but for business use, where users maybe scanning one or more items per second, ZXing and in general, camera scanning is not an option.

So, what is left? Based on my experience working with handheld ruggedized device, another option would be vendor SDKs or EMDKs. These are either free or you have to buy them. However, these are currntly available only for Android (Honeywell, Motorola, Intermec, Zebra, all of them support only Android or Xamarin Android. There is no support for Xamarin.Forms, Xamarin.iOS, Xamarin.UWP, not to mention .NET Standard 2, ...) (believe me on this, I have spent a week talking to all these vendors).

How about Nuget packages, PCL libraries, whatever? Well, turns out these are also available only for Android or Xamarin Android. Again dead end.

Then I read somewhere that scanners are just input devices, just like keyboards. Why not treat them as such and simply process key inputs using events such as TextChaned and Completed on an Xamarin.Forms Entry field. This is apparently called keyboard emulation.

This seem to be quite possible. No SDKs or EMDKs needed, no need to deal with 3rd party vendors, updates, being behind the host platform, no need to track different packages for different vendors and waste so much time, no need to bloat size of your app with packages you dont even know what they are doing.

This all makes perfect sense and the only possible dissadvantages of this method I can see are:

  • 2 input streams (keyboard and scanner) and how to distinguish btw them
  • possible need to configure a scanner

However, I dont see these as a problem and here is why. Scanners can be configured to have a prefix and / or a suffix after every and each scan. That solves 1st possible disadvantage above. But it leads to second - scanners need to be configured to have this suffix and/or prefix. However, if you control the scanners (deliver them to your customers), or if you can request or provide means to your customer to set this scanner configuration, which in my experience is mostly the case, then that is not a problem either.

My question is has anyone done this already?

I havent. I am in process of researching the option and I am thinking to give it a try but I do not see any issue with this idea. I admit, I have seen some saying that keyboard emulation is not good idea but I have also heard others swear into it. While the opposers havent provided any valuable explanation why keyboard emulation is a bad idea, everything I wrote above sounds to me a very logical and reasonable explanation why it is a great idea.

Please share your thoughts or solution if you have it and please dont read just the subject line and pollute this post with suggestions to use ZXing camera scanning or an SDK based solution for Android only, Xamarin is after all a cross-platform framework.

Can not be able to change the top bar background color! (IOS)

$
0
0

I have tried several ways: i have tried UINavigationBar.Appearance.BarTintColor = UIColor.FromHSB(351, 86, 95);
and to add it in xaml but nothing seems to work any ideas?

How to display video uploaded and recorded to database

$
0
0

hi Xamarin Forum how can I pull vid data from database and displayed into video Player

Listview selected item not working when using an image

$
0
0

I got something strange going on and I can't figure it out. I am using an image as icon that the user presses. And the image works fine but I can't click on the listview item it self nothing happens, I can delete it though. This is most likely caused by the tap gesture though I can change it to click gesture but the opposite thing happends. The listview works but not the image.

`
<ContentPage.Resources>



Blue

</ContentPage.Resources>

<ContentPage.Content>
    <RelativeLayout>
        <ListView ItemsSource="{Binding ListItems}" x:Name="llv" SelectedItem="{Binding SelectedListViewItem, Mode=TwoWay}" HasUnevenRows="True">
            <ListView.Header>
                <StackLayout Padding="10,5,0,5" VerticalOptions="Center" HorizontalOptions="Center">
                    <Label Text="{Binding Datetime}"/>
                </StackLayout>
            </ListView.Header>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout>
                            <StackLayout Orientation="Horizontal">
                                <Label Text="{Binding ItemName}" TextColor="{Binding SelectedColor}" VerticalOptions="Center" HorizontalOptions="StartAndExpand" Margin="5,5,5,5" />
                                <Label Text="{Binding DateTimeSet}" Margin="5,5,5,5" VerticalOptions="Center" HorizontalOptions="End"/>
                                <Image Source="icon.png" VerticalOptions="CenterAndExpand" HeightRequest="20" WidthRequest="20" ClassId="{Binding Id}" >
                                    <Image.GestureRecognizers>
                                        <TapGestureRecognizer
                                            Command="{Binding Path=BindingContext.PlayOrPauseButtonPressed, Source={x:Reference taskspageview}}" 
                                            NumberOfTapsRequired="1" CommandParameter="{Binding .}" >

                                        </TapGestureRecognizer>

                                    </Image.GestureRecognizers>
                                </Image>

                            </StackLayout>

                        </StackLayout>
                        <ViewCell.ContextActions>
                            <MenuItem Text="Delete" IsDestructive="True" Command="{Binding Source={x:Reference llv}, Path=BindingContext.DeleteSingleTask}"
                                CommandParameter="{Binding .}"/>
                        </ViewCell.ContextActions>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

        <controls:FloatingActionButton HorizontalOptions="CenterAndExpand" 
                                   WidthRequest="100" HeightRequest="100" 
                                   VerticalOptions="CenterAndExpand" 
                                   Command="{Binding AddButton}"
                                   Image="icon.png" ButtonColor="#03A9F4" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, 
            Property=Width, Factor=1, Constant= -98}"
            RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-98}" />
    </RelativeLayout>
</ContentPage.Content>


`

Error Java.Lang.OutOfMemoryError: Failed to allocate a 132710412 byte allocation with 1048576

$
0
0

Hi everyone, I've been working in my solution in shared project, and I´ve this error when I run my solution on a Samsung Galaxy S6 and S5 only, I'm testing my app and my solution on emulators of differents devices (Galaxy S3, LG G2, Nexus 5, Nexus 4, and google galaxy nexus) all of them in resolutions of 720x1280, 1080x1920, and with android version between 4.0 and 6.1, and all of them run without problem just with Galaxy S5 and S6 . I've seen that the problem is about of the use of large images... but all the image that I use in my forms are in xaml like backgrounds and with the hightest resolution of 648x1152..

This is the error message:

** End of managed Java.Lang.OutOfMemoryError stack trace ---
java.lang.OutOfMemoryError: Failed to allocate a 132710412 byte allocation with 1048576 free bytes and 95MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:467)
at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:497)
at android.graphics.drawable.BitmapDrawable.updateStateFromTypedArray(BitmapDrawable.java:762)
at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:724)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1215)
at android.graphics.drawable.LayerDrawable.inflateLayers(LayerDrawable.java:254)
at android.graphics.drawable.LayerDrawable.inflate(LayerDrawable.java:164)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1215)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1124)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2630)
at android.content.res.Resources.loadDrawable(Resources.java:2540)
at android.content.res.Resources.getDrawable(Resources.java:806)
at android.content.Context.getDrawable(Context.java:458)
at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:3934)
at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:3981)
at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:1969)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3160)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2481)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
**
I'm a kind of confuse of why show this error only in that kind of divices..

Xamarin Forms - How to avoid Calibration screen pops up while using app.

$
0
0

We have xamarin forms application and I am using Xam.Plugin.Geolocator plugin inorder to access the location (lat and long) service.

ISSUE:
Here, while using my app, at some cases, the OS invokes the calibration screen over my application.

It can be fixed using the below code in Xamarin.iOS :

#if DEBUG
iPhoneLocationManager.ShouldDisplayHeadingCalibration += (CLLocationManager manager) => {return false;};
#endif

BUT ISSUE IS -- HOW TO FIX THIS IN XAMARIN FORMS APPLICATION.

Please anyone help me to fix the issue. Thank you in advance.


OnCreate Does Not Get Called Predictibly In The MainActivity.cs

$
0
0

I have a debug point placed in the OnCreate and there is nothing predictable about it getting called. Most of the time it does not get called. I need a predictable solutions to ensure the OnCreate is getting called. Does anyone have a solution to this issue.

How to send an automated mail to user's mail id on a button click

$
0
0

Hi,
I am struggling to create a method that sends an automated mail to the user's mail id. It is used for authentication purpose.
It would be kind if anyone can share any suggestions on this.

Regards

Grouped Listview Expandable

$
0
0

Hello,
I create a GroupedListview with a DataTemplateSelector to have diferent margins on the viewcells of the listview, now what i need is to hide the content of every group and when the user cliks on the group name the group expandes, how can i do this?

Here are my project files:

Listview page:

https://paste.ofcode.org/pBXr3xbFZZPXMwFbZ37Ggm

ViewModel:

`public class ProductsViewModel: BindableBase
{

    public ObservableCollection<Product> Productitems { get; set; }




    public ObservableCollection<Grouping<string, Product>> Item { get; set; }





    public ProductsViewModel()
    {
        Productitems = new ObservableCollection<Product>
        {
            new Product
            {
                Img = "teste.png",
                Url = "Teste",
                Category = "Service",
                Title = "sdsadsadsdsdsa"


            },
            new Product
            {
                Img = "teste.png",
                Url = "Teste3",
                Category = "Service",
                Title = "sdsadsadsdsdsatest2"
            },
            new Product
            {
                Img = "teste.png",
                Url = "Teste2",
                Category = "School",
                Title = "sdsadsadsdsdsa"

            },
            new Product
            {
                Img = "teste.png",
                Url = "Teste4",
                Category = "Farmacy",
                Title = "sdsadsadsdsdsa"

            },
            new Product
            {
                Img = "teste.png",
                Url = "Teste7",
                Category = "Farmacy",
                Title = "sdsadsadsdsdsa"
            },
            new Product
            {
                Img = "teste.png",
                Url = "Teste7",
                Category = "Farmacy",
                Title = "sdsadsadsdsdsa"
            },
            new Product
            {
                Img = "teste.png",
                Url = "Teste9",
                Category = "School",
                Title = "sdsadsadsdsd"

            }
        };


         var sorted = from Products in Productitems
                     group Products by Products.Category into ProductsGroup
            select new Grouping<string, Models.Product>(Products Group.Key, ProductsGroup);

        Item = new ObservableCollection<Grouping<string, Models.Product>>(sorted);




    }


}`

DataTemplateSelector:

´public class AlternateColorDataTemplateSelector2 : DataTemplateSelector
{

    public DataTemplate EvenTemplate { get; set; }
    public DataTemplate UnevenTemplate { get; set; }

    private List<Product> flatList;

    protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
    {
        // TODO: Maybe some more error handling here
        if (flatList == null)
        {
            var groupedList = (ObservableCollection<Grouping<string, Product>>)((ListView)container).ItemsSource;
            flatList = groupedList.SelectMany(group => group).ToList();
        }

        return flatList.IndexOf(item as Product) % 2 == 0 ? EvenTemplate : UnevenTemplate;
    }
}´

Thanks

Animate ContentView - slide in/slide out

$
0
0

I have a ContentView and I have a button on my page. When i click the button i want the content view below to slide in top to bottom. Then i have another button and when that is clicked i want it to slide bottom to top away. Essentially i want to animate the process of changing visibility? How would I accomplish such a task?

     <ContentView x:Name="contentSlider" IsVisible="true"  BackgroundColor="#becedb" Margin="0" Grid.Row="2" VerticalOptions="Center">
                        <StackLayout Margin="10" Orientation="Horizontal" VerticalOptions="Center" HorizontalOptions="FillAndExpand">
                            <Slider MinimumTrackColor="White" Margin="0,0,5,0" HeightRequest="10"  MaximumTrackColor="White" x:Name="mileSlider" ValueChanged="SliderValueChanged"  Maximum="100" Minimum="10"  HorizontalOptions="FillAndExpand"></Slider>
                            <Label x:Name="lblMilesAway" Margin="0,5,0,0" TextColor="Black"  Text="{Binding Source={x:Reference mileSlider},Path=Value, StringFormat='up to {0:0} miles away'}"></Label>
                        </StackLayout>
                    </ContentView>

Webview not filling the screen in Xamarin Forms...why is there a gap at the top?

$
0
0

When I use a webview, it has gaps at the top and bottom, or if orientated horizontally it has gaps at the side. How do I make the webview fill the entire screen.

You can see in the screenshot the blue area is the background color of the content. Why doesn't the webview start at the top?

    <?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="WorkingWithWebview.MyPage" >
        <ContentPage.Content>
            <WebView VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" 
                     Source="https://www.google.com" WidthRequest="1000" HeightRequest="1000">

            </WebView>
        </ContentPage.Content>
    </ContentPage>

How to open Signature pad in landscape mode.

$
0
0

Hello,
I have implemented Signature Pad in my App and it is working fine. On some button click, I want Signature pad in landscape mode and on some other click event, it will back to the normal screen. So is there any way to do that?

Two Columns per row in ListView

$
0
0

In larger screen, such as iPad, I wish to use split the list view into two columns. Is it possible to do that?


working with existing database

$
0
0

Hi all,
im newbe with xamarin
i want create a commerce app in IOS-Android
I read i have to use SQLite but i need some sample to understand

First i have to port a company database (some tables) in app and i do not know how
Second what i have to install to manage the SQLite database...some like sql management studio

sorry but i study from just a week

bye

Printing on iPad from WebView

$
0
0

Hello guys,

I want to print a webview with the default printer functionalities which are available on both Android and iOS. I have a DependencyService with a Print method, which calls the platform specific code to access the printing functionalities. The problem is that it is not working on iPad, but it works on Android and iPhones.

The code for iOS is the following:

UIWebView platformWebView = (UIWebView)webView.PlatformControl;

UIPrintInteractionController printer = UIPrintInteractionController.SharedPrintController;

printer.ShowsPageRange = true;

printer.PrintInfo = UIPrintInfo.PrintInfo;
printer.PrintInfo.OutputType = UIPrintInfoOutputType.General;
printer.PrintInfo.JobName = name;

printer.PrintPageRenderer = new UIPrintPageRenderer()
{
    HeaderHeight = 40,
    FooterHeight = 40
};
printer.PrintPageRenderer.AddPrintFormatter(platformWebView.ViewPrintFormatter, 0);

printer.Present(true, (handler, completed, err) =>
{
});

I now that the printer.Present function is primary made for iPhones (http://iosapi.xamarin.com/?link=M:UIKit.UIPrintInteractionController.Present) but it should work when you use True als the first parameter (that's also conform the documentation, not in the doc at the link, but visible when you press F12 on the method in Visual Studio). The problem is that nothing is happening on the iPad when I call this method. No error, nothing.
I am aware of the method printer.PresentFromRectInView, but I don't know what I need to pass as the first two parameters (http://iosapi.xamarin.com/index.aspx?link=M:UIKit.UIPrintInteractionController.PresentFromRectInView).

Does anyone have a working printing solution for iPad?

Thanks in advance.

Regards,
Gerco

MasterDetailPage: Changing Detail Page changes MasterBehavior

$
0
0

Hello,

I am using MVVM pattern und have a ViewModes:

UserMasterPageViewModel

Inside the code behind of the UserMainPage I set the MasterBehaivior, The Detail Page and the BindingContext:

MasterBehavior = MasterBehavior.Popover;
Detail = new NavigationPage(new UserHomeDetail());
    BindingContext = new UserMainPageViewModel();

In the UserMasterPageViewModel I navigate to the selected Page by Commad

        var selectedItem = parameter as MasterPageItem;

        if (Navigation == null)
        {
            Navigation = (Application.Current.MainPage as MasterDetailPage).Detail.Navigation;               
        }

        await Navigation.PushAsync(new NavigationPage(selectedItem.Page) , true);

After clicking inside the master page on ne item, the detail page navigates correctly. But the MasterBevavior changes:

is There any options to make Rounded Corner Border for Element Entry in common xaml (android & iOS)

$
0
0

Hi Everyone, I started a project which has custom textbox(entry) with border and broder radius, if i try with simply entry - android native results with textbox(entry) style with single line at bottom and iOS native results with textbox style with border blue color.
Is there any options to make Rounded Corner Border for Element Entry with just common xaml and results in same style in android and iOS.

Syntax Error in URL for Image [.aspx URL]/[URL with parameters]

$
0
0

Hi everyone, I try to use image for my application. i try with classic URL and i have no problem.

However my co worker give me this kind of link to use an image:

http://192.168.1.48/srwssocial/SocialGetVisuel.aspx?event=savstar2018&datamatrix=xavier

I can open it on google but when i compile i have a syntax error:

<Image Source="http://192.168.1.48/srwssocial/SocialGetVisuel.aspx?event=savstar2018&datamatrix=xavier"/>

Error '=' is an unexpected token. the expected token is ";". Line 13, position 94.

I use this nugget (FFImageLoading) to see if it's better but i have still the same problem.

XAML PAGE:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms" xmlns:ffimageloading="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms" prism:ViewModelLocator.AutowireViewModel="True" x:Class="SlimPass2.Views.EventCode"> <ContentPage.Content> <StackLayout> <ffimageloading:CachedImage HorizontalOptions="Center" VerticalOptions="Center" WidthRequest="300" HeightRequest="300" DownsampleToViewSize="true" Source = "http://192.168.1.48/srwssocial/SocialGetVisuel.aspx?event=savstar2018&datamatrix=xavier"> </ffimageloading:CachedImage> <Entry Placeholder="Password" Text="{Binding TempCodeEvent}" VerticalOptions="Center" HorizontalOptions="Center"/> <Button Text="Login" Command="{Binding EventConnectionCommand}" VerticalOptions="End" BorderRadius="10" HorizontalOptions="Center"/> </StackLayout> </ContentPage.Content>

Xamarin.Forms can use this can of URL or is there an other way to use it?

Thanks for your help!

Note: i already read this doc https://docs.microsoft.com/fr-fr/xamarin/xamarin-forms/user-interface/images?tabs=vswin

Viewing all 77050 articles
Browse latest View live


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