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

Type ObjCRuntime.Selector which is passed to unmanaged code must have a StructLayout attribute.

$
0
0

Hello Xamarin.iOS developers !!!

Apple is not allowing a setfocus () operation on an html element in their WKWebview.

We have ported a solution based on objective-c to c #, attached code

Objective-C Code
- (void) keyboardDisplayDoesNotRequireUserAction { 
     SEL sel = sel_getUid "_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");

     Class WKContentView = NSClassFromString(@"WKContentView"); 
     Method method = class_getInstanceMethod(WKContentView, sel); 
     IMP originalImp = method_getImplementation(method); 

     IMP imp = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) {      
     ((void (*)(id, SEL, void*, BOOL, BOOL, id))originalImp)(me, sel, arg0, TRUE, arg2, arg3);
}); 

     method_setImplementation(method, imp); 
}  

c# code

using System;
using System.Runtime.InteropServices;

using CoreGraphics;
using Foundation;
using ObjCRuntime;
using WebKit;

namespace JBCWebManager.iOS.ViewControllers
{
    public class WKWebViewEx : WKWebView
    {
        [DllImport("/usr/lib/libobjc.dylib")] static extern IntPtr class_getInstanceMethod(IntPtr classHandle, IntPtr Selector);

        [DllImport("/usr/lib/libobjc.dylib")] static extern IntPtr method_getImplementation(IntPtr method);

        [DllImport("/usr/lib/libobjc.dylib")] static extern IntPtr imp_implementationWithBlock(ref BlockLiteral block);

        [DllImport("/usr/lib/libobjc.dylib")] static extern void method_setImplementation(IntPtr method, IntPtr imp);


        private static IntPtr _original;


        public WKWebViewEx(NSCoder coder) : base(coder)
        {
            AllowDisplayingKeyboardWithoutUserAction();
        }

        protected WKWebViewEx(NSObjectFlag t) : base(t)
        {
            AllowDisplayingKeyboardWithoutUserAction();
        }

        protected internal WKWebViewEx(IntPtr handle) : base(handle)
        {
            AllowDisplayingKeyboardWithoutUserAction();
        }

        public WKWebViewEx(CGRect frame, WKWebViewConfiguration configuration) : base(frame, configuration)
        {
            AllowDisplayingKeyboardWithoutUserAction();
        }

        static Selector selector1;

        private void AllowDisplayingKeyboardWithoutUserAction()
        {
            IntPtr @class = Class.GetHandle("WKContentView");
            NSOperatingSystemVersion iOS_11_3_0 = new NSOperatingSystemVersion(11, 3, 0);

            NSProcessInfo processInfo = NSProcessInfo.ProcessInfo;
            bool isIOS1130 = processInfo.IsOperatingSystemAtLeastVersion(iOS_11_3_0);
            if (isIOS1130)
            {
                Selector selector = new Selector("_startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:");
                IntPtr method = class_getInstanceMethod(@class, selector.Handle);
                _original = method_getImplementation(method);

                BlockLiteral block = new BlockLiteral();
                CaptureDelegate d = MyCapture;
                block.SetupBlock(d, null);
                IntPtr @override = imp_implementationWithBlock(ref block);
                method_setImplementation(method, @override);

                //IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, BOOL arg3, id arg4) 
                //{
                //    ((void(*)(id, SEL, void *, BOOL, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3, arg4);
                //});
            }
            else
            {
                selector1 = new Selector("_startAssistingNode:userIsInteracting:blurPreviousNode:userObject:");
                IntPtr method = class_getInstanceMethod(@class, selector1.Handle);
                _original = method_getImplementation(method);

                BlockLiteral block = new BlockLiteral();
                CaptureDelegate d = MyCapture;
                block.SetupBlock(d, null);
                IntPtr @override = imp_implementationWithBlock(ref block);
                method_setImplementation(method, @override);

                //IMP override = imp_implementationWithBlock(^void(id me, void* arg0, BOOL arg1, BOOL arg2, id arg3) 
                //{
                //    ((void(*)(id, SEL, void *, BOOL, BOOL, id))original)(me, selector, arg0, TRUE, arg2, arg3);
                //});
            }
        }

        [MonoNativeFunctionWrapper]
        public delegate void OriginalDelegate(NSObject me, Selector sel, IntPtr arg0, bool arg1, bool arg2, NSObject arg3);

        delegate void CaptureDelegate(NSObject me, IntPtr arg0, bool arg1, bool arg2, NSObject arg3);

        [MonoPInvokeCallback(typeof(CaptureDelegate))]
        static void MyCapture(NSObject me, IntPtr arg0, bool arg1, bool arg2, NSObject arg3)
        {
            OriginalDelegate del = (OriginalDelegate)Marshal.GetDelegateForFunctionPointer(_original, typeof(OriginalDelegate));
            del(me, selector1, arg0, true, arg2, arg3);
        }
    }
}

The code compiles correctly. The problem is very localized in the call of (me, selector1, arg0, true, arg2, arg3), and specifically in the selector1 parameter. This call executes the delegate OriginalDelegate.

The error that occurs at runtime is:

Type ObjCRuntime.Selector which is passed to unmanaged code must have a StructLayout attribute.

and it tells me that the Selector object must have the StructAttribute attribute defined. ????

Thank you so much and sorry for my bad English !!


how to put image inside frame with cs

$
0
0

hello, i wanna ask, how to put image inside frame? with cs i mean, not with xaml.
i am having hard time figure it out, can someone help me out?
thanks in advance

How to get Absolute Layout and Relative Layout to Autosize to the size of their child element

$
0
0

The design requirement is to put a label and a button on the image. The Image is in a DataTemplate of ListView. I want to use Absolute Layout. But it expand way out of the child element (image). So how to make the absolute layout the same size of the image. On the other hand if I use relative layout it also expands out of the child element. But it takes less space than absolute layout. I know Absolute Layout and RelativeLayout are the best for this scenario. But they were leaving lots of empty space between list view items. Please help me out and explain how to use both of these layouts appropriately in order to size them according to their child elements. The code is as follows


<ListView.ItemTemplate>

                     <AbsoluteLayout >

                        <Image Source="BuyersCard.png" > </Image>

                       <Label Text="{Binding Name}" AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds=".1,.2"></Label>

                            <Button Text="Contact" BorderColor="Red" AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds=".7,.2"></Button>

                    </AbsoluteLayout>
                  </ViewCell>       
            </DataTemplate>
        </ListView.ItemTemplate>

    </ListView>

How do overlap in Xamarin forms?

$
0
0

Does the concept of z-index? The picture shows that there is no overlap. enter image description here How to set z-index? the top two custom select box

<AbsoluteLayout Padding="10,10,10,10" VerticalOptions="FillAndExpand">

    <ui:BoxSelector x:Name="selectorExchangs"
                    AbsoluteLayout.LayoutBounds="0,0,0.5,0.3"
                    AbsoluteLayout.LayoutFlags="All"
                    BackgroundColor="Transparent"
                    CommandAfterChanged="{Binding ExchangesAfterChangedCommand}"
                    Items="{Binding ExchangesList}"
                    LabelPath="Name"
                    PanelColor="#f9f9f9"
                    SelectedItem="{Binding SelectedExchange}"
                    SelectorLabel="EXCHANGE" />

    <ui:BoxSelector AbsoluteLayout.LayoutBounds="1,0,0.5,0.3"
                    AbsoluteLayout.LayoutFlags="All"
                    BackgroundColor="Transparent"
                    CommandAfterChanged="{Binding TradingPairAfterChangedCommand}"
                    Items="{Binding AvailableTradinPairsList}"
                    LabelPath="PriceCurrencyName"
                    PanelColor="#f9f9f9"
                    SelectedItem="{Binding SelectedTraingPair}"
                    SelectorLabel="CURRENCY" />

And all the rest. Chart, data, e.t.c

`<StackLayout AbsoluteLayout.LayoutBounds="1,1,1,0.9" AbsoluteLayout.LayoutFlags="All">...</StackLayout>`

BoxSelector.xaml(content view), Reusable ContentView extends

<ContentView.Resources>
    <ResourceDictionary x:Name="AppDictionary">
        <Color x:Key="BackgroundColor">#f9f9f9</Color>
        <Color x:Key="BorderColor">#e2e2e2</Color>
        <Style x:Key="InternalViewStyle" TargetType="ContentView">
            <Setter Property="BackgroundColor" Value="{StaticResource BackgroundColor}" />
            <Setter Property="VerticalOptions" Value="Fill" />
            <Setter Property="Padding" Value="5,5,5,5" />
        </Style>
        <Style x:Key="BorderStyle" TargetType="ContentView">
            <Setter Property="BackgroundColor" Value="{StaticResource BorderColor}" />
            <Setter Property="Padding" Value="1,1,1,1" />
        </Style>
    </ResourceDictionary>
</ContentView.Resources>

<StackLayout BindingContext="{x:Reference Name=ContentView}" HorizontalOptions="FillAndExpand">
    <ContentView BackgroundColor="#f5f5f5" HorizontalOptions="FillAndExpand">
        <StackLayout>
            <ContentView Style="{StaticResource BorderStyle}">
                <ContentView Style="{StaticResource InternalViewStyle}">
                    <StackLayout Orientation="Horizontal">
                        <StackLayout x:Name="selectorBox"
                                     BackgroundColor="{Binding PanelColor}"
                                     HorizontalOptions="FillAndExpand"
                                     Orientation="Horizontal">
                            <StackLayout HorizontalOptions="StartAndExpand" Orientation="Horizontal">
                                <Label FontSize="12"
                                       HorizontalOptions="FillAndExpand"
                                       Text="{Binding SelectorLabel}"
                                       TextColor="#cccccc" />
                                <Label x:Name="valueLabe"
                                       BackgroundColor="{Binding PanelColor}"
                                       FontSize="13"
                                       HorizontalOptions="FillAndExpand"
                                       Text="Choose"
                                       TextColor="#313131" />
                            </StackLayout>
                            <StackLayout HorizontalOptions="EndAndExpand">
                                <Label Text="+" TextColor="#313131" />
                            </StackLayout>
                        </StackLayout>
                    </StackLayout>
                </ContentView>
            </ContentView>

            <Grid x:Name="boxSelectorGrid"
                  BackgroundColor="#f5f5f5"
                  Padding="10,10,10,10">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
            </Grid>

        </StackLayout>
    </ContentView>
</StackLayout>

Emoji View like whatsup

$
0
0

Good Day All

i have lots of emojis, i want to create the same view whatsup create when someone select the emoji button as depicted below

i tried to put them i a stacklayout and make its orientation horizontal and scroll but it does not fit well .

Thanks

when all BindableProperties get initialized from XAML regardless their declaration order?

$
0
0

This happens a lot when creating custom controls (mostly in code only). In many cases some properties (if not all) are dependent on each other, like for example: ItemsSource and DisplayMemberPath .. etc- I need to know the value of DisplayMemberPath while I'm iterating over the ItemsSource to render controls (set the Text of a Label to the value of DisplayMemberPath).

when I process Items in the ItemsSource collection I want to make sure that the DisplayMemberPath property has also been set,
when using the propertyChanged delegate of the ItemsSourceProperty it's likely that the DisplayMemberPathProperty is null, if it's set in XAML after ItemsSource:

<controls:FlowList ItemsSource="{Binding Items}" DisplayMemberPath="Title"/>

so, where is the proper place where I'll be sure every property has been set regardless their declaration order?

How to implement Firebase In-App Messaging

$
0
0

Hi guys,
I want to add Firebase in-app messaging in my Xamarin.Droid project how can I do this.
Which nuget can I use for this.
I already have implementing firebase other services.
So I just want to understand the client part.

Is it possible to dynamically change the color of the navigation bar?

$
0
0

Hey guys,

I'm trying to implement a theme feature in my app and did a bit of searching here + around Google looking for a way to (dynamically) change the color of the navigation bar multiple times by binding but did not have much success. I am currently pushing a new navigation page with the new color, however, I was hoping to implement a more elegant solution. If anything is unclear please let me know. Thank you!


How to identify and reference to the dependent Assembly or Library among Projects? resolve Error CS0

$
0
0

How to identify and reference to the dependent Assembly or Library among Projects? resolve Error CS0012?

Error:

Error CS0012
The type 'IAsyncOperation<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows.Foundation.FoundationContract, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'.
ViewModels

My UWP app-solution has three projects:

Project-1 (UWP):
Target version: Windows 10 Anniversay Edition (10.0; build 14393)
Min version: Windows 10 Anniversay Edition (10.0; build 14393)
References:
Analyzers
HockeySDK.UWP
Microsoft.NETCore.UniversalWindowsPlatform
PcscSdk
Serilog
Serilog.Sinks.RollingFileAlternate.MultiPlatform
System.Reactive
UniversalWindows
Xam.Plugin.Battery
Xam.Plugin.PopupMenu
Xam.Plugins.Settings
Xamarin.Forms
Dependencies: Projects\ViewModel

Project-2 (Forms):
Target framework: .NET Standard 1.4
Dependencies: NuGet\
Xam.Plugin.Battery (3.0.1)
Xam.Plugin.PopupMenu (1.1.0)
Xam.Plugins.Settings (3.1.1)
Xamarin.Controls.SignaturePad.Form (2.2.0)
Xamarin.Forms (2.5.0.122203)
Dependencies: Projects\ViewModel
Dependencies: SDK\NETStandard.Library(2.0.1)

Project-2 (ViewModel):
Target framework: .NET Standard 1.4
Dependencies: Assemblies\ Windows.Foundation.UniversalApiContract
Dependencies: NuGet\
System.Reactive (3.1.1)
Xam.Plugin.Battery (3.0.1)
Xam.Plugins.Settings (3.1.1)
Xamarin.Forms (2.5.0.122203)
Dependencies: SDK\NETStandard.Library(2.0.1)

Login with Facebook

$
0
0

Hi people, my name's Leonardo, i have a solution of xamarin forms and it is a application android and ios, i need create a login that use facebook login, but, all help in internet not help me because nothing is functional, I tryed use Xamarin.auth and I no have success, please help me, sorry, my inglesh not is good.

Enjoying Xamarin Forms :)

$
0
0

Not a discussion or question per-se but after a wobbly start I'm really enjoying using Xamarin Forms. I just wanted to make a point of saying to others considering using Xamarin (in my case Forms) to give it a go.

I read a lot of bad things about it when researching beforehand, I'm not sure if those things are valid or not as I don't have years under my belt or a project of a larger size but as a newcomer its working out well so far.

Connect Failure in Xamarin IOS

$
0
0

Some time i am facing issue of Connect Failure when I hit the web api in Xamarin IOS project. API is working fine and issue is in connection. If any one have an idea to solve this issue or have a link through which i can solve this issue. please send me because i have tried many solution but couldn't solve it.

Please check the issue log below and if anyone have a perfect solution of my problem. please suggest me

{System.AggregateException: One or more errors occurred. ---> System.Net.WebException: Error: ConnectFailure (Too many open files) ---> System.Net.Sockets.SocketException: Too many open files at System.Net.Sockets.Socket..ctor (AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType) [0x00060] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System/System.Net.Sockets/Socket.cs:214 at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x000f6] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System/System.Net/WebConnection.cs:189 --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00065] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System/System.Net/HttpWebRequest.cs:946 at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (IAsyncResult iar, System.Func2 endFunction, System.Action1 endAction, System.Threading.Tasks.Task1 promise, Boolean requiresSynchronization) <0x1002da730 + 0x0005b> in :0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003b] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:199 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () <0x10027a4f0 + 0x0001b> in :0
at System.Net.Http.HttpClientHandler+c__async0.MoveNext () [0x003d6] in /Library/Frameworks/Xamarin.iOS.framework/Versions/9.6.1.9/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:372
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003b] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:199
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () <0x10027a4f0 + 0x0001b> in :0 at System.Net.Http.HttpClient+c__async0.MoveNext () [0x000a9] in /Library/Frameworks/Xamarin.iOS.framework/Versions/9.6.1.9/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:274 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional (Boolean includeTaskCanceledExceptions) [0x00014] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/threading/Tasks/Task.cs:2168 at System.Threading.Tasks.Task1[TResult].GetResultCore (Boolean waitCompletionNotification) <0x1002d9dc0 + 0x0006f> in :0
at System.Threading.Tasks.Task1[TResult].get_Result () <0x1002d9d50 + 0x0002b> in :0 at RSystemApp.Controller.HolidayController.GetLeaveInformation (Int64 employeeId) [0x00025] in D:\Mukesh\TFSCode\RSIMobileApp\RSystemApp\RSystemApp\Controller\HolidayController.cs:83 ---> (Inner Exception #0) System.Net.WebException: Error: ConnectFailure (Too many open files) ---> System.Net.Sockets.SocketException: Too many open files at System.Net.Sockets.Socket..ctor (AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType) [0x00060] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System/System.Net.Sockets/Socket.cs:214 at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x000f6] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System/System.Net/WebConnection.cs:189 --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00065] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System/System.Net/HttpWebRequest.cs:946 at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (IAsyncResult iar, System.Func2 endFunction, System.Action1 endAction, System.Threading.Tasks.Task1 promise, Boolean requiresSynchronization) <0x1002da730 + 0x0005b> in :0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003b] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:199 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () <0x10027a4f0 + 0x0001b> in :0
at System.Net.Http.HttpClientHandler+c__async0.MoveNext () [0x003d6] in /Library/Frameworks/Xamarin.iOS.framework/Versions/9.6.1.9/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:372
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003b] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:199
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:170
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/3051/5f11db87/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:142
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () <0x10027a4f0 + 0x0001b> in :0 at System.Net.Http.HttpClient+c__async0.MoveNext () [0x000a9] in /Library/Frameworks/Xamarin.iOS.framework/Versions/9.6.1.9/src/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:274 <--- }

HelloAR: The Andy.OBJ cannot be replaced

$
0
0

I tried to modify the "Andy.OBJ" in HelloAR e.g. using the 3D Builder of Win10, but not successed.
May I know what software I should uses? e.g. it come together with a .MTL which I don't know how to uses in the MainActivity.cs to call.

And, any reference for creating geometry in OnDrawFrame? I want to connect all Anchor to form a polygon on surface but don't know how to do it.

Thanks

Xamarin.Form How to get (Image,Header,Text) into a Listview without XAML

$
0
0

I think its a liteview i need in this case.

This is what i want to achieve.

I want every item in the listview to have a image,Header,text

The binding needs to be in the code to.

I have found this on a website.

var listView = new ListView ();
listView.ItemsSource = produkter ;
listView.ItemTemplate = new DataTemplate();

But cant figure out the rest.

List produkter = new List();
produkter = productlist();

public List productlist()
{
public String Header {get;set;}
public String text {get;set;}
public String image {get;set;}
}

Thanks alot if you can help with this.

Picker pops up twice

$
0
0

I have a simple picker inside a list view and on my devices when I use my finger to scroll or tap it pops up twice

I have verified this on multiple devices and I know it is not my code - it's just a picker

best

JK


Problem with building Android Wear

$
0
0

I am trying to create an Android Wear project with xamarin, but I cannot get my project to run.
I updated all the packages to the latest version

My android wear project is a standalone app so I set the minimum SDK version to 23.

These are the most important packages that I am using in my android wear project:
Xamarin.GooglePlayServices.Wearable: v42.1021.1
Xamarin.Android.Wear: v2.0.1.1
Xamarin.Android.Support.Wear: v26.1.0.1
Xamarin.Android.Support.v4: v26.1.0.1

I always get the following exception at starting my project:
<br /> 1>obj\Debug\android\src\mono\android\support\wear\widget\SwipeDismissLayout_OnDismissedListenerImplementor.java:8: error: package android.support.wear.widget.SwipeDismissLayout does not exist<br /> 1> android.support.wear.widget.SwipeDismissLayout.OnDismissedListener<br /> 1> ^<br /> 1>obj\Debug\android\src\mono\android\support\wear\widget\SwipeDismissLayout_OnPreSwipeListenerImplementor.java:8: error: package android.support.wear.widget.SwipeDismissLayout does not exist<br /> 1> android.support.wear.widget.SwipeDismissLayout.OnPreSwipeListener<br /> 1> ^<br /> 1>obj\Debug\android\src\mono\android\support\wear\widget\SwipeDismissLayout_OnSwipeProgressChangedListenerImplementor.java:8: error: package android.support.wear.widget.SwipeDismissLayout does not exist<br /> 1> android.support.wear.widget.SwipeDismissLayout.OnSwipeProgressChangedListener<br /> 1> ^<br /> 1>Note: Some input files use or override a deprecated API.<br /> 1>Note: Recompile with -Xlint:deprecation for details.<br /> 1>Note: Some input files use unchecked or unsafe operations.<br /> 1>Note: Recompile with -Xlint:unchecked for details.<br /> 1>3 errors<br /> 1> error: package android.support.wear.widget.SwipeDismissLayout does not exist<br /> 1> android.support.wear.widget.SwipeDismissLayout.OnDismissedListener<br /> 1><br /> 1> error: package android.support.wear.widget.SwipeDismissLayout does not exist<br /> 1> android.support.wear.widget.SwipeDismissLayout.OnPreSwipeListener<br /> 1><br /> 1> error: package android.support.wear.widget.SwipeDismissLayout does not exist<br /> 1> android.support.wear.widget.SwipeDismissLayout.OnSwipeProgressChangedListener<br /> 1><br /> 1>Done building project "NormalWearTest.csproj" -- FAILED.<br /> 1>Build FAILED.<br />

This is the file where the problem is located (SwipeDismissLayout_OnDismissedListenerImplementor.java):
<br /> package mono.android.support.wear.widget;</p> <p>public class SwipeDismissLayout_OnDismissedListenerImplementor<br /> extends java.lang.Object<br /> implements<br /> mono.android.IGCUserPeer,<br /> android.support.wear.widget.SwipeDismissLayout.OnDismissedListener<br /> {<br /> /** @hide */<br /> public static final String __md_methods;<br /> static {<br /> __md_methods = <br /> "";<br /> mono.android.Runtime.register ("Android.Support.Wear.Widget.SwipeDismissLayout+IOnDismissedListenerImplementor, Xamarin.Android.Support.Wear, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", SwipeDismissLayout_OnDismissedListenerImplementor.class, __md_methods);<br /> }</p> <pre><code>public SwipeDismissLayout_OnDismissedListenerImplementor () { super (); if (getClass () == SwipeDismissLayout_OnDismissedListenerImplementor.class) mono.android.TypeManager.Activate ("Android.Support.Wear.Widget.SwipeDismissLayout+IOnDismissedListenerImplementor, Xamarin.Android.Support.Wear, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "", this, new java.lang.Object[] { }); } private java.util.ArrayList refList; public void monodroidAddReference (java.lang.Object obj) { if (refList == null) refList = new java.util.ArrayList (); refList.add (obj); } public void monodroidClearReferences () { if (refList != null) refList.clear (); }

}

How to reduce File Provider memory footprint?

$
0
0

Any ideas/tricks on how to reduce the memory footprint of my NSFileProviderExtension more than I already have?

I have done the following:
1. Got rid of JSON.net
2. Got rid of System.Http.Net
3. Run file provider in Release mode (only build ARM64)

The file provider starts out with a footprint of about 11.5 MB on iPhone6 and 13.5 on iPad Pro (appex size is 2.3MB). Of course, when it hits 15 MB, BOOM!

For comparison, a file provider I built with XCode starts out with a memory footprint of about 3.4MB.

I can run for a while on my iPhone 6 but running on any iPad Pro quits upon first navigation.

I have a Pro account so I don't have access to the Xamarin Profiler.

Unfortunately, for iOS11 I needed to add Mono.Data.Sqlite. I hadn't seen this problem before adding sqlite. See references below:

Here are my iOS build settings:

Geolocator Plugin by @JamesMontemagno not working for IOS background in xamarin forms?

$
0
0

Hello,
I have to send the device gps coordinate to the database in the time interval of 2 minutes for background and foreground mode in IOS xamarin forms?
Here is my code using geolocation plugin :
private async void GetCurrentLocation()
{
try
{
var hasPermission = await Utils.CheckPermissions(Permission.Location);
if (!hasPermission)
return;

            if (tracking)
            {
                CrossGeolocator.Current.PositionChanged -= CrossGeolocator_Current_PositionChanged;
                CrossGeolocator.Current.PositionError -= CrossGeolocator_Current_PositionError;
            }
            else
            {
                CrossGeolocator.Current.PositionChanged += CrossGeolocator_Current_PositionChanged;
                CrossGeolocator.Current.PositionError += CrossGeolocator_Current_PositionError;
            }

            if (CrossGeolocator.Current.IsListening)
            {
                await CrossGeolocator.Current.StopListeningAsync();
                ImageTick.Source = "cross.png";
                await DisplayAlert("Location Denied", "Please enable your GPS(location services)", "OK");
                tracking = false;
                count = 0;
            }
            else
            {
                Positions.Clear();
                if (await CrossGeolocator.Current.StartListeningAsync(TimeSpan.FromSeconds(1), 10, true, new Plugin.Geolocator.Abstractions.ListenerSettings
                {
                    ActivityType = Plugin.Geolocator.Abstractions.ActivityType.AutomotiveNavigation,
                    AllowBackgroundUpdates = true,
                    DeferLocationUpdates = true,
                    DeferralDistanceMeters = 1,
                    DeferralTime = TimeSpan.FromSeconds(1),
                    ListenForSignificantChanges = true,
                    PauseLocationUpdatesAutomatically = false
                }))
                {
                    ImageTick.Source = "tick.png";
                    tracking = true;
                }
            }
        }
        catch (Exception ex)
        {
            await DisplayAlert("Uh oh", "Something went wrong, but don't worry we captured for analysis! Thanks.", "OK");
        }
    }




void CrossGeolocator_Current_PositionError(object sender, PositionErrorEventArgs e)
{

    var abc = "Location error: " + e.Error.ToString();
}

void CrossGeolocator_Current_PositionChanged(object sender, PositionEventArgs e)
{

    Device.BeginInvokeOnMainThread(() =>
    {
        var position = e.Position;
        Positions.Add(position);
        if(position != null)
            { 
            ImageTick.Source = "tick.png";
            }
        else
            { 
            ImageTick.Source = "cross.png";
            DisplayAlert("Location Denied", "Please enable your GPS(location services)", "OK");
        }   
        count++;
            DateTime endTime = DateTime.Now;
            TimeSpan span = endTime.Subtract(startTime);
               Console.WriteLine(span);
               if(span.Minutes >= 2)
               {

                   Settings.CurrentLat = position.Latitude.ToString();
                   Settings.CurrentLon = position.Longitude.ToString();
                   **SetPosition();**
                   startTime = endTime;
               }
        var x = $"{count} updates";
        var y = string.Format("Time: {0} \nLat: {1} \nLong: {2} \nAltitude: {3} \nAltitude Accuracy: {4} \nAccuracy: {5} \nHeading: {6} \nSpeed: {7}",
            position.Timestamp, position.Latitude, position.Longitude,
            position.Altitude, position.AltitudeAccuracy, position.Accuracy, position.Heading, position.Speed);

    });
}

as per the above code Kindly give me the solution so that I can run my IOS app in xamarin forms for foreground and background mode.
//Note SetPosition() is the function I am using to hit the API.

Delete Web Cache / Javascript Storage

$
0
0

I have an app that is using an http server to serve files to a Web View. The web viewers are caching image links which is causing broken images when their paths changes.

I can delete the web store on Android and UWP but I cannot figure out how to properly with iOS.

Android:

Android.Webkit.WebStorage.Instance.DeleteAllData();

UWP:

Windows.UI.Xaml.Controls.WebView.ClearTemporaryWebDataAsync();

I have tried the following with no luck:

        NSHttpCookieStorage.SharedStorage.RemoveCookiesSinceDate(NSDate.DistantPast);
        WKWebsiteDataStore.DefaultDataStore.FetchDataRecordsOfTypes(WKWebsiteDataStore.AllWebsiteDataTypes, (NSArray records) =>
        {
            for (nuint i = 0; i < records.Count; i++)
            {
                var record = records.GetItem<WKWebsiteDataRecord>(i);

                WKWebsiteDataStore.DefaultDataStore.RemoveDataOfTypes(
                    websiteDataTypes: record.DataTypes,
                    date: new[] { record },
                    completionHandler: () => { });
            }

            for (nuint i = 0; i < records.Count; i++)
            {
                var record = records.GetItem<WKWebsiteDataRecord>(i);

                WKWebsiteDataStore.DefaultDataStore.RemoveDataOfTypes(record.DataTypes,
                    new[] { record }, () => { Console.Write($"deleted: {record.DisplayName}"); });
            }
        });

        NSUrlCache.SharedCache.RemoveAllCachedResponses();



        NSUrlCache.SharedCache.DiskCapacity = 0;
        NSUrlCache.SharedCache.MemoryCapacity = 0;

SoundPool pause and resume

$
0
0

Hi all,
I just released my first mobile game (tepoball) and one of my customers is experiencing a problem with sound. Sometimes the music keeps playing even the app is in the background. He was not able to Isolate the problem and uses a Moto G5 device with Android 8.1. What the app basically does is when the OnPause event of the Activity is raised it calls the method SoundPool.AutoPause and the same for the OnResume event with AutoResume. Did anyone have the same problem and came up with a solution?

Viewing all 204402 articles
Browse latest View live


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