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

Xamarin app crashes with error-Got a SIGSEGV while executing native code. This usually indicates a f

$
0
0

I am developing desktop app for mac using Xamarin on visual studio but when i run the app it crashes unexpectedly, without throwing any exception just gives below log -

=================================================================

Native Crash Reporting

Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries

used by your application.

=================================================================

Native stacktrace:

 (No frames) 

=================================================================

Basic Fault Address Reporting

Memory around native instruction pointer (0x7fff6694765d):0x7fff6694764d 49 ba f8 ff ff ff ff 7f 00 00 4c 23 17 49 89 f3 I.........L#.I..
0x7fff6694765d 45 23 5a 18 49 c1 e3 04 4d 03 5a 10 49 3b 33 75 E#Z.I...M.Z.I;3u
0x7fff6694766d 0a 4d 8b 5b 08 4d 31 d3 41 ff e3 49 83 3b 01 76 .M.[.M1.A..I.;.v
0x7fff6694767d 13 49 83 c3 10 49 3b 33 75 f1 4d 8b 5b 08 4d 31 .I...I;3u.M.[.M1

=================================================================

Managed Stacktrace:

  at <unknown> <0xffffffff>
  at Foundation.NSObject:xamarin_release_managed_ref <0x0008d>
  at Foundation.NSObject:ReleaseManagedRef <0x00022>
  at NSObject_Disposer:Drain <0x0018a>
  at <Module>:runtime_invoke_void_object <0x000f0>
  at <unknown> <0xffffffff>
  at AppKit.NSApplication:NSApplicationMain <0x00164>
  at AppKit.NSApplication:Main <0x000f2>
  at StyleGuard.MainClass:Main <0x00032>

at :runtime_invoke_void_object <0x000f0>

We are unable to find exact cause of app crash.
Thanks,
Pooja.


xamarin.mac - NSAlert crashes the mac app.

$
0
0

I am developing the desktop app for mac using xamarin but app is crashes because of below code:

NSAlert alert = new NSAlert();
alert.MessageText = string.Format("Are you sure you want to delete the style collection: {0} v{1}?", sc.Name, sc.Version);
alert.AddButton("Delete");
alert.AddButton("Cancel");
alert.AlertStyle = NSAlertStyle.Critical;

                bool bDelete = alert.RunModal() != 1001;
                alert.DangerousRelease();

and below is the app crash logs:

=================================================================

Native Crash Reporting

Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries

used by your application.

=================================================================

Native stacktrace:

 (No frames) 

=================================================================

Basic Fault Address Reporting

Memory around native instruction pointer (0x7fff6f87165d):0x7fff6f87164d 49 ba f8 ff ff ff ff 7f 00 00 4c 23 17 49 89 f3 I.........L#.I..
0x7fff6f87165d 45 23 5a 18 49 c1 e3 04 4d 03 5a 10 49 3b 33 75 E#Z.I...M.Z.I;3u
0x7fff6f87166d 0a 4d 8b 5b 08 4d 31 d3 41 ff e3 49 83 3b 01 76 .M.[.M1.A..I.;.v
0x7fff6f87167d 13 49 83 c3 10 49 3b 33 75 f1 4d 8b 5b 08 4d 31 .I...I;3u.M.[.M1

=================================================================

Managed Stacktrace:

  at <unknown> <0xffffffff>
  at Foundation.NSObject:xamarin_release_managed_ref <0x0008d>
  at Foundation.NSObject:ReleaseManagedRef <0x00022>
  at NSObject_Disposer:Drain <0x0018a>
  at <Module>:runtime_invoke_void_object <0x000f0>
  at <unknown> <0xffffffff>
  at AppKit.NSApplication:NSApplicationMain <0x00164>
  at AppKit.NSApplication:Main <0x000f2>
  at StyleGuard.MainClass:Main <0x00032>

at :runtime_invoke_void_object <0x000f0>

I am not able to find the cause of app crash if anyone know please help.

Thanks
Pooja.

Xamarin app crashes with error-Got a SIGSEGV while executing native code. This usually indicates a f

$
0
0

I am developing desktop app for mac using Xamarin on visual studio but when i run the app it crashes unexpectedly, without throwing any exception just gives below log -

=================================================================

Native Crash Reporting

Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries

used by your application.

=================================================================

Native stacktrace:

 (No frames) 

=================================================================

Basic Fault Address Reporting

Memory around native instruction pointer (0x7fff6694765d):0x7fff6694764d 49 ba f8 ff ff ff ff 7f 00 00 4c 23 17 49 89 f3 I.........L#.I..
0x7fff6694765d 45 23 5a 18 49 c1 e3 04 4d 03 5a 10 49 3b 33 75 E#Z.I...M.Z.I;3u
0x7fff6694766d 0a 4d 8b 5b 08 4d 31 d3 41 ff e3 49 83 3b 01 76 .M.[.M1.A..I.;.v
0x7fff6694767d 13 49 83 c3 10 49 3b 33 75 f1 4d 8b 5b 08 4d 31 .I...I;3u.M.[.M1

=================================================================

Managed Stacktrace:

  at <unknown> <0xffffffff>
  at Foundation.NSObject:xamarin_release_managed_ref <0x0008d>
  at Foundation.NSObject:ReleaseManagedRef <0x00022>
  at NSObject_Disposer:Drain <0x0018a>
  at <Module>:runtime_invoke_void_object <0x000f0>
  at <unknown> <0xffffffff>
  at AppKit.NSApplication:NSApplicationMain <0x00164>
  at AppKit.NSApplication:Main <0x000f2>
  at StyleGuard.MainClass:Main <0x00032>

at :runtime_invoke_void_object <0x000f0>

We are unable to find exact cause of app crash.
Thanks,
Pooja.

Can we make a cross platform app for cab application like Ola and Uber?

$
0
0

If yes, then which type of libraries we add to it?

Xamarin UWP release build take much more time to complie

$
0
0

Hi Team,
I am trying to deploy the UWP in Microsoft store. Its takes much longer time to compile.
Could you please suggest some technical tips to optimize the release deployment

Shell Navigation between Multiple Fly Outs

$
0
0

I have two fly outs, each has multiple tabs.
When my app loads, it loads on the first tab of my first fly out.
If I navigate to the 2nd fly out, and then back the first fly out, and try to select any items, the app crashes with a null reference exception.
What is weird, this does not happen on Android.

In the App class I originally had
MainPage = new AppShell();

I read somewhere that this would work for ios
MainPage = new NavigationPage(new AppShell());

but this did not work either.

// First Flyout
FlyoutItem Title="Items" Style="{StaticResource BaseStyle}"
Tab Title="Tab One"
ShellContent ContentTemplate="{DataTemplate local:TabOneview}"
Tab
Tab Title="Tab Two"
ShellContent ContentTemplate="{DataTemplate local:TabTwoView}"
Tab
Tab Title="Tab Three" >
ShellContent ContentTemplate="{DataTemplate local:TabThreeView}"
Tab
FlyoutItem

// Second flyout
FlyoutItem Title="Profiles" Style="{StaticResource BaseStyle}"
Tab Title="Alpha"
ShellContent ContentTemplate="{DataTemplate local:AlphaView}"
Tab
Tab Title="Bravo"
ShellContent ContentTemplate="{DataTemplate local:BravoView}"
Tab
Tab Title="Charlie"
ShellContent ContentTemplate="{DataTemplate local:CharlieView}"
Tab
Tab Title="Atmospherics" Icon="SunDarkTheme.png"
ShellContent ContentTemplate="{DataTemplate local:AtmosphericProfileView}"
Tab
FlyoutItem

How to update a “label” in ViewController.cs from another C# file in Xamarin MacOS development?

$
0
0

I am working on a small MacOS app in Xamarin and using 'Visual Studio for MAC'. I am unable to figure out how to update the value of a label in the ViewController.cs file from another .cs file.

`using System;
using AppKit;
using Foundation;

namespace FramesMac
{

public partial class ViewController : NSViewController
{
    public ViewController(IntPtr handle) : base(handle)
    {
    }

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();
        // Do any additional setup after loading the view.
        lbl_message.StringValue="Processing..."
    }

    public override NSObject RepresentedObject
    {
        get
        {
            return base.RepresentedObject;
        }
        set
        {
            base.RepresentedObject = value;
            // Update the view, if already loaded.
        }
    }

}
}`

I simply want to update lbl_message.StringValue="Processing..." from another .cs file.

Xamarin.Android EvaluateJavaScriptAsync() NullPointerException

$
0
0

I'm developing an app with Xamarin.Forms. The main part in this app is a webview with some native functions. In the debug simulator and on iOS everything is working fine, but when I run the app on a real Android device or Release in the simulator, the app is crashing with the following error:

android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Forms.WebView.EvaluateJavaScriptAsync (System.String script) [0x00079] in <68ab566bdacc435a8adf7cece6abb272>:0
at Project.Pages.WebViewControl.Droid.WebViewDroid+<>c__DisplayClass30_0.b__0 () [0x0006d] in :0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in <04061722500a4bdc9319897f1eff920b>:0
at Android.App.SyncContext+<>c__DisplayClass2_0.b__0 () [0x00000] in :0
at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in :0
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in :0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.24(intptr,intptr)
at mono.java.lang.RunnableImplementor.n_run(Native Method)
at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6815)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
The method, where the error occurs:

WebViewDroid.cs

using System;
using System.Diagnostics;
using Project.Services;
using Xam.Plugin.WebView.Abstractions;
using Xamarin.Forms;

namespace Project.Pages.WebViewControl.Droid
{
public class WebViewDroid : WebView, IWebViewControl
{
public bool IsActive { get; set; }
public string Url { get; set; }
public bool LoadingFinished { get; set; }

    public IWebContainerPage ParentPage { set; get; }

    public WebViewDroid()
    {
        Navigated += WebView_Navigated;
    }

    public event IOnNavgigationStartedHandler OnNavigationStartedHandler;
    public event IOnNavgigationCompletedHandler OnNavigationCompletedHandler;
    public event IOnNavgigationErrorHandler OnNavigationErrorHandler;

    protected void NavigationStarted(EventArgs e)
    {
        OnNavigationStartedHandler?.Invoke(this, e);
    }
    protected void NavigationCompleted(EventArgs e)
    {
        OnNavigationCompletedHandler?.Invoke(this, e);
    }
    protected void NavigationError(EventArgs e)
    {
        OnNavigationErrorHandler?.Invoke(this, e);
    }


    private void WebView_Navigated(object sender, WebNavigatedEventArgs e)
    {
        LoadingFinished = true;
        NavigationCompleted(new EventArgs());
    }

    public void InjectJavaScript(string script)
    {
        Device.BeginInvokeOnMainThread(async () =>
        {
            await EvaluateJavaScriptAsync(script); <----- Here the app is crashing. If I comment it out, there is no crash but some native functions won't work anymore
        });
    }

    public void Load(bool forceReload)
    {
        IsActive = true;

        if (LoadingFinished && forceReload)
        {
            InjectJavaScript("window.location.reload(true);");
        }
        else
        {
            Source = Url;
        }
    }

    void Handle_OnNative(PostNativeArgs obj)
    {
        //This method is only called on android
        if (IsActive)
        {
            ParentPage.PerformActionByUrlAsync(obj.Url);
        }
    }

    public void Hide()
    {
        //Source = "about:blank";
        IsActive = false;
        IsVisible = false;
    }

    public void Show()
    {
        DependencyService.Get<IWebViewService>().OnNative = Handle_OnNative;
        DependencyService.Get<IWebViewService>().OnError = Handle_OnError;

        IsVisible = true;
        IsActive = true;
    }


    public void PerformBack()
    {
        GoBack();
    }

    void Handle_OnError()
    {
        if (IsActive)
        {
            Hide();
            NavigationError(new EventArgs());
        }
    }

}

}
WebContainerPage.xaml.cs

public WebContainerPage()
{
InitializeComponent();

        BindingContext = this;

        WebViewControl = Device.RuntimePlatform == Device.Android ? WebViewDroid : (IWebViewControl)WebViewIOS;

        WebViewControl.ParentPage = this;
        WebViewControl.OnNavigationCompletedHandler += WebView_OnNavigationCompletedHandler;
        WebViewControl.OnNavigationErrorHandler += WebViewControl_OnNavigationErrorHandler;
    }

public void InjectJavaScript(string script)
{
WebViewControl.InjectJavaScript(script); <---- here I call the method from WebViewDroid.cs
}
Can someone help me with this?


WebView set Source to local pdf file

$
0
0

Hi guys,

Im wondering how I can load a local saved pdf file into the webview. For Android I use Source = $"file:///android_asset/pdfjs/web/viewer.html?file={"file:///" + WebUtility.UrlEncode(pathtopdf)}";

How can I set the source for the file on iOS? It's located like this: /var/mobile/Containers/Data/Application/CD7DC3FD-AF7F-493C-BA4A-A4FFD5AA9BB3/Documents/pdf/document.pdf

I hope someone can help me, thank you and best regards
ChRiS

SkiaSharp - SKImage.Encode Causes Memory Leaks

$
0
0

Hello,

I'm using SkiaSharp in my Xamarin.iOS project. The following lines cause memory leak, and can not understand why it happens at all.

using (var image = SKImage.FromBitmap(bitmap)) {
    using (var data = image.Encode(SKImageEncodeFormat.Png, 100)) {
        using (var stream = File.OpenWrite(path)) {
            data.SaveTo(stream);
        }
    }
}

I have attached screenshot from the instruments window.

Do you have any suggestions or workaround to fix this?

Edit: I'm using SkiaSharp version 1.54.1.

Thanks,
Koray

Shell Bottom Tabs, how do I get full color icons?

$
0
0

I'm not a fan of the monochrome icons, is there a way to get it to use the full color icons there?

SkiaSharp - canvas.DrawText and canvas.DrawRect Causes Memory Leaks

$
0
0

I have memory leaks. I draw a Map on Canvas and draw a location hotspot on top of it. But after few seconds i got
Exception: Foundation.MonoTouchException: Objective-C exception thrown. Name: NSMallocException Reason: Failed to grow buffer

Fragment of StackTrace

`at ObjCRuntime.Runtime.ThrowNSException (System.IntPtr ns_exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.6.0.12/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:406
at ObjCRuntime.Runtime.throw_ns_exception (System.IntPtr exc) [0x00000] in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/runtime/Delegates.generated.cs:128
at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
at (wrapper managed-to-native) SkiaSharp.SkiaApi.sk_typeface_create_from_file(void*,int)
at Skia
Sharp.SKTypeface.FromFile (System.String path, System.Int32 index) [0x0002c] in :0
at OccupancyViewModule.Map.EstateSmartCanvas.get_TextFontFamily () [0x00000] in C:\projects\raboon\EstateMobile\Modules\OccupancyViewModule\Map\EstateSmartCanvas.cs:73
at OccupancyViewModule.Map.EstateSmartCanvas.DrawLocationHotSpot (SkiaSharp.SKCanvas canvas, SkiaSharp.SKImageInfo info, SkiaSharp.SKMatrix matrix) [0x000e1] in C:\projects\raboon\EstateMobile\Modules\OccupancyViewModule\Map\EstateSmartCanvas.cs:487
at OccupancyViewModule.Map.EstateSmartCanvas.DrawAllHotSpot (SkiaSharp.SKCanvas canvas, SkiaSharp.SKImageInfo info) [0x00028] in C:\projects\raboon\EstateMobile\Modules\OccupancyViewModule\Map\EstateSmartCanvas.cs:363
--- End of stack trace from previous location where exception was thrown ---

at (wrapper managed-to-native) SkiaSharp.SkiaApi.sk_typeface_create_from_file(void*,int)
at SkiaSharp.SKTypeface.FromFile (System.String path, System.Int32 index) [0x0002c] in :0
at OccupancyViewModule.Map.EstateSmartCanvas.get_TextFontFamily () [0x00000] in C:\projects\raboon\EstateMobile\Modules\OccupancyViewModule\Map\EstateSmartCanvas.cs:73
at OccupancyViewModule.Map.EstateSmartCanvas.DrawLocationHotSpot (SkiaSharp.SKCanvas canvas, SkiaSharp.SKImageInfo info, SkiaSharp.SKMatrix matrix) [0x000e1] in C:\projects\raboon\EstateMobile\Modules\OccupancyViewModule\Map\EstateSmartCanvas.cs:487
at OccupancyViewModule.Map.EstateSmartCanvas.DrawAllHotSpot (SkiaSharp.SKCanvas canvas, SkiaSharp.SKImageInfo info) [0x00028] in C:\projects\raboon\EstateMobile\Modules\OccupancyViewModule\Map\EstateSmartCanvas.cs:363 0 CoreFoundation 0x000000018181d820 FF63481D-FB6A-353B-B2C1-AC4EAECF594D + 1226784`

My hotspot draw code as below

`public void DrawAllHotSpot(SKCanvas canvas, SKImageInfo info)
{
canvas.Save();
SKMatrix matrix = _touchSensitiveBitmap.Matrix;
canvas.Concat(ref matrix);
try
{
DrawBookalbeHotSpot(canvas, info, matrix);
DrawLocationHotSpot(canvas, info, matrix);
}
catch (Exception e)
{
Console.WriteLine($"Exception: {e}");
}
canvas.Restore();
}

    public void DrawBookalbeHotSpot(SKCanvas canvas, SKImageInfo info, SKMatrix matrix)
    {
        float x = 0, y = 0;
        string text, bookableName;                      
        SKRect textBounds = new SKRect();
        SKRect textBookableBounds = new SKRect();
        using (SKPaint textIconPaint = new SKPaint())
        {
            // Set Style for the character outlines
            textIconPaint.Style = SKPaintStyle.Fill;
            textIconPaint.TextSize = FontSize;
            textIconPaint.IsAntialias = true;
            textIconPaint.Style = SKPaintStyle.Fill;
            textIconPaint.TextEncoding = SKTextEncoding.Utf32;
            textIconPaint.Color = Color.White.ToSKColor();
            // Set TextSize based on screen size
            using (SKPaint buttonFillPaint = new SKPaint())
            {
                buttonFillPaint.Style = SKPaintStyle.StrokeAndFill;                    
                using (SKPaint buttonTextPaint = new SKPaint())
                {
                    buttonTextPaint.Style = SKPaintStyle.StrokeAndFill;
                    buttonTextPaint.Color = Color.Black.ToSKColor();
                    buttonTextPaint.TextSize = 10;
                    buttonTextPaint.IsAntialias = true;
                    buttonTextPaint.TextEncoding = SKTextEncoding.Utf32;
                    buttonTextPaint.Typeface = TextFontFamily;
                    textIconPaint.Typeface = IconFontFamily;
                    var bookables = _quickBookingPopupViewViewModel?.Rows.Where(item => item?.Bookable != null && item?.Bookable?.LocationId == _filterPopupViewModel.ChosenLocation.LocationId);
                    foreach (var item in bookables)
                    {
                        x = (item?.Bookable?.PositionX ?? 0) * _touchSensitiveBitmap.bitmap.Width;
                        y = (item?.Bookable?.PositionY ?? 0) * _touchSensitiveBitmap.bitmap.Height;
                        switch (item?.Bookable?.CurrentAvailability)
                        {
                            case ServiceModule.EstateWebservice.AvailabilityStatus.Available:
                                text = IconIconFree;
                                buttonFillPaint.Color = SKColor.Parse(FreeColorHexString);
                                break;
                            case ServiceModule.EstateWebservice.AvailabilityStatus.Unavailable:
                                text = IcontIconBusy;
                                buttonFillPaint.Color = SKColor.Parse(BookedColorHexString);
                                break;
                            default:
                                text = IconPartiallyFree;
                                buttonFillPaint.Color = SKColor.Parse(PartialColorHexString);
                                break;
                        }
                        bookableName = item?.Bookable?.ObjectName ?? string.Empty;
                        if (bookableName.StartsWith(item?.Bookable?.ObjectLocation?.LocationName))
                        {
                            bookableName = bookableName.Replace(item?.Bookable?.ObjectLocation?.LocationName, String.Empty);
                        }
                        #region Draw Bookable Object Icon
                        textIconPaint.MeasureText(text, ref textBounds);
                        float x1 = (float)(x - textBounds.MidX);
                        float y1 = (float)(y - textBounds.MidY);
                        x1 = x1 > 0 ? x1 : 0;
                        y1 = y1 > 0 ? y1 : 0;
                        SKRect frameRect = textBounds;
                        frameRect.Offset(x1, y1);
                        frameRect.Inflate(2, 1);
                        canvas.DrawRect(frameRect, buttonFillPaint);
                        canvas.DrawText(text, x1, y1, textIconPaint);
                        #endregion
                        #region Draw Bookable Object name if zoom size reached a certain level
                        if (matrix.ScaleX > ZoomThresholdToShowBookableName)
                        {
                            textIconPaint.MeasureText(bookableName, ref textBookableBounds);
                            x1 = (float)(x - textBookableBounds.MidX);
                            y1 = (float)(y + textBookableBounds.MidY);
                            x1 = x1 > 0 ? x1 : 0;
                            y1 = y1 > _touchSensitiveBitmap.Display.Height ? _touchSensitiveBitmap.Display.Height : y1;
                            frameRect = textBookableBounds;
                            frameRect.Offset(x1, y1);
                            frameRect.Inflate(2, 1);
                            //canvas.DrawRect(frameRect, buttonFillPaint);
                            canvas.DrawText(bookableName, x1, y1, buttonTextPaint);
                        }
                        #endregion
                    }
                }
            }
        }
    }        

    public void DrawLocationHotSpot(SKCanvas canvas, SKImageInfo info, SKMatrix matrix)
    {
        float x = 0, y = 0;
        string text,iconText = string.Empty;
        SKRect textBounds = new SKRect();
        SKRect textIconBounds = new SKRect();
        using (SKPaint textIconPaint = new SKPaint())
        {
            // Set Style for the character outlines
            textIconPaint.Style = SKPaintStyle.Fill;
            textIconPaint.TextSize = FontSize;
            textIconPaint.IsAntialias = true;
            textIconPaint.Style = SKPaintStyle.Fill;
            textIconPaint.TextEncoding = SKTextEncoding.Utf32;
            textIconPaint.Color = Color.White.ToSKColor();
            textIconPaint.Typeface = IconFontFamily;
            // Set TextSize based on screen size
            using (SKPaint buttonFillPaint = new SKPaint())
            {
                buttonFillPaint.Style = SKPaintStyle.StrokeAndFill;
                buttonFillPaint.Color = SKColor.Parse("96979C");
                using (SKPaint buttonTextPaint = new SKPaint())
                {
                    buttonTextPaint.Style = SKPaintStyle.StrokeAndFill;
                    buttonTextPaint.Color = Color.White.ToSKColor();
                    buttonTextPaint.TextSize = FontSize;
                    buttonTextPaint.IsAntialias = true;
                    buttonTextPaint.TextEncoding = SKTextEncoding.Utf32;
                    buttonTextPaint.Typeface = TextFontFamily;
                    using (SKPaint iconBackColor = new SKPaint())
                    {
                        iconBackColor.Style = SKPaintStyle.StrokeAndFill;

                        foreach (var item in _quickBookingPopupViewViewModel?.Rows.Where(item => item?.Location != null))
                        {
                            x = (item?.Location?.PositionX ?? 0) * _touchSensitiveBitmap.bitmap.Width;
                            y = (item?.Location?.PositionY ?? 0) * _touchSensitiveBitmap.bitmap.Height;
                            text = (item?.Location?.LocationName?.Length > LocationNamePrefixLenth) ? item?.Location?.LocationName?.Substring(0, LocationNamePrefixLenth) : item?.Location?.LocationName;
                            text = ".." + text;// Add Extra Space to Show (+/-/X) icon
                            iconBackColor.Color = GetLocationButtonColor(item?.Location, ref iconText);

                            #region Paint Location Name
                            textIconPaint.MeasureText(text, ref textBounds);
                            float x1 = (float)(x - textBounds.MidX);
                            float y1 = (float)(y - textBounds.MidY);
                            x1 = x1 > 0 ? x1 : 0;
                            y1 = y1 > 0 ? y1 : 0;
                            SKRect frameRect = textBounds;
                            frameRect.Offset(x1, y1);
                            frameRect.Inflate(2, 1);
                            canvas.DrawRect(frameRect, buttonFillPaint);
                            canvas.DrawText(text, x1, y1, buttonTextPaint);
                            #endregion

                            #region paint Location Icon (+/-/x)                            
                            iconBackColor.MeasureText(iconText, ref textIconBounds);
                            SKRoundRect frameRoundedRect = new SKRoundRect(textIconBounds, 5, 5);
                            frameRoundedRect.Offset(x1-1, y1-1);
                            frameRoundedRect.Inflate(2, 1);
                            canvas.DrawRoundRect(frameRoundedRect, iconBackColor);
                            canvas.DrawText(iconText, x1-5, y1-1, textIconPaint);
                            #endregion
                        }
                    }
                }
            }

        }
    }`

what did I make wrong?!

Setting startup page in Shell throws errors

$
0
0

I was trying to figure out how I can set a particular shell item as deafult page when the app starts. I am using the Xaminals example to experiment with.

    <FlyoutItem Route="animals"
                Title="Animals"
                FlyoutDisplayOptions="AsMultipleItems">
        <Tab Title="Domestic"
                  ...
        </Tab>
        <ShellContent Route="monkeys" x:Name="monkeyItem"
                      Style="{StaticResource MonkeysShell}"
                      Title="Monkeys"
                      Icon="monkey.png"
                      ContentTemplate="{DataTemplate views:MonkeysPage}" />
                  ...
    </FlyoutItem>

In the AppShell.xaml.cs I'm setting the CurrentItem:

        public AppShell()
        {
            ....

            CurrentItem = monkeyItem;
        }

I run the app, and the page with the monkeys is displayed as default. This is correct.

However, when I click on an item in the listview, I'm getting a null reference exception. This does not happen if I don't set the default item.

>   at Xamarin.Forms.ShellSection.OnPushAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x00013] in d:\agent\1\s\Xamarin.Forms.Core\Shell\ShellSection.cs:470 
>   at Xamarin.Forms.ShellSection.GoToAsync (Xamarin.Forms.NavigationRequest request, System.Collections.Generic.IDictionary`2[TKey,TValue] queryData, System.Boolean animate) [0x00200] in d:\agent\1\s\Xamarin.Forms.Core\Shell\ShellSection.cs:285 
>   at Xamarin.Forms.Shell.GoToAsync (Xamarin.Forms.ShellNavigationState state, System.Boolean animate, System.Boolean enableRelativeShellRoutes) [0x001df] in d:\agent\1\s\Xamarin.Forms.Core\Shell\Shell.cs:444 
>   at Xaminals.Views.MonkeysPage.OnCollectionViewSelectionChanged (System.Object sender, Xamarin.Forms.SelectionChangedEventArgs e) [0x00055] in /Users/jasper/dev_personal/Xamarin_Forms___Xaminals/Xaminals/Views/MonkeysPage.xaml.cs:18 
>   at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in <19853c43ab794d18ab1a33ecb65b3c4d>:0 
>   at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <8c07a09624c14764b43f6b946a5a1f23>:0 
>   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <8c07a09624c14764b43f6b946a5a1f23>:0 
>   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <8c07a09624c14764b43f6b946a5a1f23>:0 
>   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.36(intptr,intptr)

Is this a bug, or am I doing something wrong? Is there another way to set the default page?

Getting Started With iOS Development

$
0
0

I am very intrigued about iOS development. However, what I have, and what I need to start this process may hinder me from being able to do this. This is why I am here writing this forum to figure out how I can go about this, maybe someone here reading this will think of a solution that I haven't thought of.

Anyways, I have a Windows PC both a desktop and laptop computers, both PC's have Windows 10 installed on them, and both has a AMD processor.

I have done some research online on both Google search and YouTube. I know that XCode is the main IDE that iOS developers use to develope their apps. With having a Window PC, I know XCode is not supported on Windows PCs. So, I done another research and I discovered that Visual Studio 2019 has multiple libraries, including mobile libraries such as iOS and Android. Visual Studio 2019 is a pretty good alternative when you don't have access to a Mac with XCode on it. However, the problem I will run into with Visual Studio 2019 is debugging my apps. To debug my apps I am forced to remotely log into a Mac or use a virtual mac which isn't free. I'm not interested in paying for a virtual Mac. Getting my own Mac, using a friend's Mac, or going to a public library to use one is not an option for me. So, is there any other solutions?

Thanks!

Getting Started With iOS Development

$
0
0

I am very intrigued about iOS development. However, what I have, and what I need to start this process may hinder me from being able to do this. This is why I am here writing this forum to figure out how I can go about this, maybe someone here reading this will think of a solution that I haven't thought of.

Anyways, I have a Windows PC both a desktop and laptop computers, both PC's have Windows 10 installed on them, and both has a AMD processor.

I have done some research online on both Google search and YouTube. I know that XCode is the main IDE that iOS developers use to develope their apps. With having a Window PC, I know XCode is not supported on Windows PCs. So, I done another research and I discovered that Visual Studio 2019 has multiple libraries, including mobile libraries such as iOS and Android. Visual Studio 2019 is a pretty good alternative when you don't have access to a Mac with XCode on it. However, the problem I will run into with Visual Studio 2019 is debugging my apps. To debug my apps I am forced to remotely log into a Mac or use a virtual mac which isn't free. I'm not interested in paying for a virtual Mac. Getting my own Mac, using a friend's Mac, or going to a public library to use one is not an option for me. So, is there any other solutions?

Thanks!


Firebase notification not being delivered in Xamarin forms ios

$
0
0

Hi,
I have integrated the firebase cloudmessaging in my app and i am getting the FCM_token, but not receiving the notifications from firebase console.
I have the packages-------------- xamarine.firebase.ios.cloudmessaging(3.1.2), xamarine.firebase.ios.InstanceID(3.2.1).
Also i have tired the latest packages ,but it keep crashing the app.
In firebasse console i have added the APNs key generated from the appledeveloper account.

Here is my appdelegates.cs

using System;
using System.Collections.Generic;
using System.Linq;
using CarouselView.FormsPlugin.iOS;
using Firebase.CloudMessaging;
using Foundation;
using Microsoft.Identity.Client;
using MSTnTAPP.Helpers;
using MSTnTAPP.Services;
using MSTnTAPP.Util;
using UIKit;
using UserNotifications;
using Xamarin.Forms;

namespace MSTnTAPP.iOS

{

// The UIApplicationDelegate for the application. This class is responsible for launching the 

// User Interface of the application, as well as listening (and optionally responding) to 

// application events from iOS.

[Register("AppDelegate")]

public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate,

IUNUserNotificationCenterDelegate,
IMessagingDelegate
{

    public override bool FinishedLaunching(UIApplication app, NSDictionary options)

    {
        debugAlert("", "FinishedLaunching-called");
        global::Xamarin.Forms.Forms.Init();
        FormsControls.Touch.Main.Init();
        App thisApp = null;
        thisApp = new App();
        LoadApplication(thisApp);
        if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
        {
            // iOS 10 or later
            var authOptions = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound;
            UNUserNotificationCenter.Current.RequestAuthorization(authOptions, (granted, error) =>
            {
                System.Console.WriteLine(granted);
            });
            // For iOS 10 display notification (sent via APNS)
            UNUserNotificationCenter.Current.Delegate = this;
            // For iOS 10 data message (sent via FCM)
            Messaging.SharedInstance.Delegate = this;
        }
        else
        {
            // iOS 9 or before
            var allNotificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound;
            var settings = UIUserNotificationSettings.GetSettingsForTypes(allNotificationTypes, null);
            UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
        }
        UIApplication.SharedApplication.RegisterForRemoteNotifications();
        Firebase.Core.App.Configure();
        Messaging.SharedInstance.Delegate = this;
        var token = Messaging.SharedInstance.FcmToken ?? "";
        NotificationServiceContext.DEVICE_INSTANCE_ID_TOKEN = token;
        Console.WriteLine($"FCM token: {token}");

        //to get document directory
        AppSettingKeys.STORAGE_PATH = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        var authenticationService = DependencyService.Get<IAuthHelper>();
        authenticationService.SetParent(this);
        CarouselViewRenderer.Init();
        return base.FinishedLaunching(app, options);
    }
    [Export("messaging:didReceiveRegistrationToken:")]
    public void DidReceiveRegistrationToken(Messaging messaging, string fcmToken)
    {
        Console.WriteLine($"Firebase registration token: {fcmToken}");
        debugAlert("", "DidReceiveRegistrationToken-called");
        NotificationServiceContext.DEVICE_INSTANCE_ID_TOKEN = fcmToken;
    }
    public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo)
    {
        debugAlert("", "ReceivedRemoteNotification-called");
        // If you are receiving a notification message while your app is in the background,
        // this callback will not be fired till the user taps on the notification launching the application.
        // TODO: Handle data of notification
        // With swizzling disabled you must let Messaging know about the message, for Analytics
        //Messaging.SharedInstance.AppDidReceiveMessage (userInfo);
        // Print full message.
        Console.WriteLine(userInfo);
    }
    /*private void connectFCM()
    {
        Messaging.SharedInstance.Connect((error) =>
        {
            if (error == null)
            {
                Messaging.SharedInstance.Subscribe("/topics/all");
            }
            System.Diagnostics.Debug.WriteLine(error != null ? "error occured" : "connect success");
        });
    }*/
    public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
    {
        AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(url);
        return true;
    }
    public override void OnActivated(UIApplication uiApplication)
    {
        debugAlert("", "OnActivated-called");
        //connectFCM();
        base.OnActivated(uiApplication);
    }
    public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
    {
        debugAlert("", "RegisteredForRemoteNotifications-called");

if DEBUG

        Firebase.CloudMessaging.Messaging.SharedInstance.SetApnsToken(deviceToken,ApnsTokenType.Sandbox);

endif

if RELEASE

        Firebase.InstanceID.InstanceId.SharedInstance.SetApnsToken(deviceToken, ApnsTokenType.Prod);

endif

    }
    public void DidRefreshRegistrationToken(Messaging messaging, string fcmToken)
    {
        //throw new NotImplementedException();
        debugAlert("", $"DidRefreshRegistrationToken-called{fcmToken}");
        NotificationServiceContext.DEVICE_INSTANCE_ID_TOKEN = fcmToken;
    }
    // public override DidReceiveRemoteNotification(Messaging messaging, string fcmToken)
    //{
    //  throw new NotImplementedException();
    //}

    // iOS 9 <=, fire when recieve notification foreground

    public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
    {
        // If you are receiving a notification message while your app is in the background,
        // this callback will not be fired till the user taps on the notification launching the application.
        // TODO: Handle data of notification

        // With swizzling disabled you must let Messaging know about the message, for Analytics
        //Messaging.SharedInstance.AppDidReceiveMessage (userInfo);
        //debugAlert("", "DidReceiveRemoteNotification-called");
        // Print full message.
        Console.WriteLine(userInfo);

        completionHandler(UIBackgroundFetchResult.NewData);
    }

    public void ApplicationReceivedRemoteMessage(RemoteMessage remoteMessage)
    {
        debugAlert("", "ApplicationReceivedRemoteMessage-called");
        Console.WriteLine(remoteMessage);
    }
    private void debugAlert(string title, string message)
    {
        var alert = new UIAlertView(title ?? "Title", message ?? "Message", null, "Cancel", "OK");
        alert.Show();
    }
}

}

I am getting stuck here,please let me know if anything i am missing.

documents from UWP 2

documents from3

VideoView implementation via LibVLCSharp

$
0
0

I'm implementing video stream using LibVLCSharp. If I'm using the example and creating VideoView in code - everything works fine.

I need to play a video on a half of a screen, not on a full screen, but the app crashes , video is not loading.

The thing that do work:

 _libVLC = new LibVLC();
_mediaPlayer = new MediaPlayer(_libVLC)
   {
     EnableHardwareDecoding = true
   };
_videoPlayer = new VideoView(this) { MediaPlayer = _mediaPlayer };
AddContentView(_videoPlayer, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
_videoPlayer.MediaPlayer.Play(media);

The other variant that crashes:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">
    <LibVLCSharp.Platforms.Android.VideoView
        android:id="@+id/videoPlayer"
        android:layout_width="match_parent"
        android:layout_height="300dp"/>
    <Button/>...

_libVLC = new LibVLC();
_mediaPlayer = new MediaPlayer(_libVLC)
  {
    EnableHardwareDecoding = true
  };
_videoPlayer = FindViewById<VideoView>(Resource.Id.videoPlayer);
_videoPlayer.MediaPlayer = _mediaPlayer;
var media = new Media(_libVLC, url, FromType.FromLocation);
_videoPlayer.MediaPlayer.Play(media);

54+88

Viewing all 204402 articles
Browse latest View live


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