Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

How to tell what version of iOS your app is running on?

$
0
0

I'm trying to figure out what version of iOS my app is running on so I can change a behavior for iOS 7. The Apple docs say to use NSFoundationVersionNumber, but I cannot find an equivalent in Xamarin.iOS. The closest I could find is NSProcessInfo.ProcessInfo.OperatingSystemVersionString, but that returns a string like this: "Version 10.8.5 (Build 12F37)" for iOS7.


Azure notify app when element inserted into table

$
0
0

The idea is we have a mobile app backed by an azure database. I am wondering if there is any way to send a notification to the mobile app in case an element has been added to a specific table. The app will receive this notification, check what value has been inserted into that azure sql table and then make a decision whether to send a warning to the app user or not, like a push notification.

Can this be achieved and if yes how ? Any help is appreciated.

Custom renderer "The name 'Control' doesnt exist in the current format"

$
0
0

I'm creating a custom renderer for android in my Xamarin forms projects

here is the code:

`
[assembly: ExportRenderer(typeof(GradientBoxView), typeof(GradientBoxViewRenderer))]
namespace TournamentsMaker.Droid.CustomRenderers
{
public class GradientBoxViewRenderer : BoxRenderer
{
public GradientBoxViewRenderer(Context context) : base(context) { }
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);

        if (Control != null)
        {
            var gradientBoxView = Element as GradientBoxView;

            var linearGradient = gradientBoxView.Color;

            //colors
            var nativeColors = linearGradient.LinearGradientStops.Select(gs => gs.Color).ToArray();

            int[] colors = new int[nativeColors.Count()];
            for (int i = 0; i < nativeColors.Length; i++)
                colors[i] = nativeColors[i].ToAndroid();

            var gradient = new GradientDrawable(Utils.AndroidUtils.ToGradientDrawableFlow(linearGradient.Flow), colors);

            Control.SetBackgroundDrawable(gradient);
        }
    }
}

}
`

Of course the required name spaces are imported but I didn't mention them because they is many of them.
The Control property doesnt get recognized even after rebuilding and cleaning the solution ?

This class is located at
.Android.CustomRederers

Why don't Lottie Animations work in Xamarin.Android?

$
0
0

In the Lottie docs, they say to use this to play your animation:

<com.airbnb.lottie.LottieAnimationView
    android:id="@+id/animation_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:lottie_fileName="hello-world.json"
    app:lottie_loop="true"
    app:lottie_autoPlay="true" />

In Android design, it says

'app' is an undeclared prefix.

Does anyone know why this is happening?

Thank you!

How do I put an SVG image file on my Xamarin iOS Project?

$
0
0

I was looking for snippets but they were all pointing to Xamarin Forms, Can anyone please provide nuget packages or any documentation on how do I put an SVG image file on my Xamarin iOS Project?

Can I Use My designer.cs Files For Designing the Xamarin.Forms Pages?

$
0
0
Good Day, I have. A Windows Forms Application And I want to know if I can use the designer.cs files of it in Xamarin.Forms to show it the same

App icon doesn't display every time.

$
0
0

Does any one has the same issue? I am using Visual Studio 7.5.1 and when I run the App on any simulator the icon seems missing and also happens when I create an ipa, I see that icon is missing.

Is anyone seeing the same issue? Any solutions that worked for you?

Connection Failure when build .APK

$
0
0

Hi guys,

I wanna ask about my aplication.

I build project with web reference (private/local internet).

My Application succesfully work on debug. That can connect with Local service and do like read insert to SQL Server.

But when I build to APK that application cant connecting to service and to result "CONNECTION FAILURE"

I was check permisson.internet too

SO, Pls help me to resolve my problem.

Ty

Best Regard


It is obligatory to need to use a Mac for iOS Development and Publish an app in Xamarin Forms?

$
0
0
I need to know that, so I buy a Mac

Open Wifi Setting Page and return back to app without using Back button

$
0
0

My app is running in full screen mode and the home, back and menu button is hide. How do I go back my app after I open Wifi Setting page?

Insert at the end of ListView.GroupHeaderTemplate

$
0
0

I have a listview with GroupHeaderTemplate and ItemTemplate , and i want to insert two buttons (Accept , Reject) at the end of each listItem , I have order and each order have items and each item has details so the order id and username shown in GroupHeaderTemplate and the items in the itemTemplate .. but I cant set the two buttons at the end of the items and with each order (not repeated with each item) .

<ContentPage.Content>
    <StackLayout >
        <Label Text="لا يوجد لديك طلبات حالياً" IsVisible="{Binding EmptyLableVisible}"  ></Label>


        <ActivityIndicator IsRunning="{Binding IsLoading}" HorizontalOptions="FillAndExpand"
                           VerticalOptions="FillAndExpand"/>



        <ListView ItemsSource="{Binding RequestedItems}" 
                  SeparatorVisibility="None"
                  SeparatorColor="Transparent"
                  IsGroupingEnabled="True"
                  GroupDisplayBinding="{Binding Key}"
                  GroupShortNameBinding="{Binding Key}"
                  HasUnevenRows="True"
                  HorizontalOptions="FillAndExpand"
                           VerticalOptions="FillAndExpand"

        >



            <ListView.GroupHeaderTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout>
                            <StackLayout Orientation="Vertical">
                                <Label Text="Requersted UserId" FontAttributes="Bold"/>
                                <Label Text="{Binding Key.RequestUserName}"/>
                            </StackLayout>
                            <StackLayout Orientation="Vertical">
                                <Label Text="Order Id" FontAttributes="Bold"/>
                                <Label Text="{Binding Key.Id}"/>
                            </StackLayout>

                        </StackLayout>


                    </ViewCell>

                </DataTemplate>



            </ListView.GroupHeaderTemplate>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <Frame>
                            <StackLayout >

                                <Label Text="{Binding Name}"/>
                                <Label Text="{Binding Size}"/>
                                <Label Text="{Binding Url}"/>

                            </StackLayout>
                        </Frame>

                    </ViewCell>

                </DataTemplate>

            </ListView.ItemTemplate>


        </ListView>

    </StackLayout>
</ContentPage.Content>`

Embedded Resource Image Not Displaying in app

$
0
0

I just started learning xamarin and I can't get a local image to display. I'm following a tutorial and looking at the documentation, but I"m still having issues. I don't see what I'm doing different from the documentation. I named the image an embedded resource in properties and I set the page as the default page in app.xaml.cs. All I get is a blank app with no image or anything.

    `   MainPage = new Images.LocalImage();`

I've been stuck on this for a few days now so any help is greatly appreciated.

Screenshot showing image path and property settings

LocalImage.xaml

<?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="Images.LocalImage">

    <Image x:Name="myLocalImage" Aspect="AspectFit"/>

</ContentPage>  

LocalImage.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace Images
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class LocalImage : ContentPage
    {
        public LocalImage ()
        {
            InitializeComponent ();



            myLocalImage.Source = ImageSource.FromResource("Images.background.jpg");


        }
    }
}

Xamarin Forms Map error on Andriod

$
0
0

I'm getting a Unhandled Exception when debug project.

/////////////////////////////////////////////////////////////////////////////////
Unhandled Exception:

Java.Lang.NumberFormatException: For input string: "@2131493172"
/////////////////////////////////////////////////////////////////////////////////

here the code :
LoadApplication(new App());
at MainActivity.cs

Please help me!

How to Send SMS using At Command?

$
0
0

I need to create app send sms from sim1 (samsung 2 sim card ) using AT Command,
how to do this. Many thanks

Is there a way to downgrade xamarin.iOS version to 11.8 in Visualstudio for Mac?


Problem with AlertDialog using TaskCompletionSource

$
0
0

Hi,
I'm trying to wait on the result of an AlertDialog using TaskCompletionSource with the following code:

using Android.App;
using Android.Widget;
using Android.OS;
using System.Threading.Tasks;

namespace App1
{
    [Activity(Label = "App1", Theme = "@style/Theme.AppCompat.Light.NoActionBar", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {
        int count = 1;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            Button button = FindViewById<Button>(Resource.Id.MyButton);

            button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
            button.Click += delegate { CallAlertDialogTest(); };

            //CallAlertDialogTest();
        }

        public enum MessageResult
        {
            NONE = 0,
            OK = 1,
            CANCEL = 2,
            ABORT = 3,
            RETRY = 4,
            IGNORE = 5,
            YES = 6,
            NO = 7
        }

        private void CallAlertDialogTest()
        {
            MessageResult result = AlertDialogTest().Result;

            System.Diagnostics.Debug.WriteLine($"Result = {result.ToString()}");
        }

        private async Task<MessageResult> AlertDialogTest()
        {
            var tcs = new TaskCompletionSource<MessageResult>();

            Android.Support.V7.App.AlertDialog.Builder alertBuilder = new Android.Support.V7.App.AlertDialog.Builder(this);
            alertBuilder.SetTitle("Test Alert Dialog");
            alertBuilder.SetMessage("Click Yes or No");
            alertBuilder.SetPositiveButton("Yes", (senderAlert, args) =>
            {
                tcs.TrySetResult(MessageResult.OK);
            });
            alertBuilder.SetNegativeButton("No", (senderAlert, args) =>
            {
                tcs.TrySetResult(MessageResult.NO);
            });
            alertBuilder.SetCancelable(false);


            Dialog alertDialog = alertBuilder.Create();
            //Android.Support.V7.App.AlertDialog alertDialog = alertBuilder.Create();
            //RunOnUiThread(() =>
            //{
            //await Task.Run(() =>
            //{
            alertDialog.Show();
            //});


            return await tcs.Task;
        }
    }
}

It always hangs, and doesn't display the alert dialog. It displays if I set tcs outside the eventhandlers, but that somewhat defeats the purpose. I've tried numerous permutation such as running it on the UI thread etc, but all to no avail.

Can anyone tell me what my error is, and how to resolve it?

Thanks

Azure authentication from push when app is closed

$
0
0

I have a Xamarin Forms App that makes a request to a web service passing an chached authentication token after receiving a push notification. This works fine on Android and iPhone when the app is running in the foreground or minimised. But if the app is force closed it will still receive the push notification but will fail getting the cached Azure Authentication Context at this line:
var authContext = new AuthenticationContext(authority);
Giving the error:
Error authenticating: You MUST call Xamarin.Forms.Init(); prior to using it.

This is the same code regardless of whether the app is running or closed.
Can anyone let me know how to authenticate when the app is closed? Or how to call Forms.Init() when a push notification is received.
Any help would be greatly appreciated.

How to create alert window with list and search option for android and ios in xamarin forms?

$
0
0

Hi guys

I want alert window with dynamic list and search option for list.

For this requirement i searched over internet but i didn't get solution for it.

Can you please highlight me how to achieve it?

HttpClient has very large response time on Xamarin Android

$
0
0

I have followed the article https://docs.microsoft.com/en-gb/xamarin/android/app-fundamentals/http-stack?tabs=macos to make Xamarin Android application support TLS 1.2

When I call rest service, It takes 10+ seconds from Xamarin Android while 2 seconds from Xamarin IOS project.

Both project uses same PLC HttpClient code to call same service.

Code:

HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, restQuery);
response = await client.SendAsync(request);
string result = await response.Content.ReadAsStringAsync();

Raising this issue as it has considerable difference between IOS & Android environment in Xamarin.

PCSC - LIte using

$
0
0

Hi dear collages . I need to create little android app for testing smart card with (PCSC with reader ACS ACR38U-ND) . But i couldn't find any sample about it .
I download the PCSC library from package manager and tried to implement the code .
IN GitHUb > pcsc-sharp

var contextFactory = ContextFactory.Instance; using (var context = contextFactory.Establish(SCardScope.System)) { System.Diagnostics.Debug.WriteLine("Currently connected readers: "); var readerNames = context.GetReaders(); foreach (var readerName in readerNames) { System.Diagnostics.Debug.WriteLine("\t" + readerName); } }

But when i debug , i get the following error .

`
07-19 01:36:39.665 W/Mono ( 2821): DllImport unable to load library 'dlopen failed: library "/data/app-lib/pcsc_lite_new_version.pcsc_lite_new_version-2/libpcsclite.so.1" not found'.
Unhandled Exception:

System.DllNotFoundException: libpcsclite.so.1
`

So i don't know how to test it . Need tour help and suggestion .

Viewing all 204402 articles
Browse latest View live


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