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

Xamarin - Ios Binding (MT5210) Error

$
0
0

I am getting below error when using IOS Binding in Xamarin Project :-

std::__1::__hash_table<std::__1::__hash_value_type<objc_object* __strong, objc_object* __strong>, std::__1::__unordered_map_hasher<objc_object* __strong, std::__1::__hash_value_type<objc_object* __strong, objc_object* __strong>, MJKeyHasher, true>, std::__1::__unordered_map_equal<objc_object* __strong, std::__1::__hash_value_type<objc_object* __strong, objc_object* __strong>, MJKeyEqual, true>, std::__1::allocator<std::__1::__hash_value_type<objc_object* __strong, objc_object* __strong> > >::erase(std::__1::__hash_const_iterator<std::__1::__hash_node<std::__1::__hash_value_type<objc_object* __strong, objc_object* __strong>, void>>) in navigationSDK_03_.a(MJPriorityDictionary.o) Native linking

navigationSDK_03_.a is my .a file generated from XCode project.

Can anyone guide me on this.

Thanks.


Xamarin.Forms iOS spotlight icon is default

$
0
0

Hello I have problem with my iOs app. I have set a all icon, and it work on menu, and notifications. But not in spotlights and settings, ther is a default xamarin icon and I dont know how to fix it. Someone has an idea?

( In Assets.xcassets, i file appIcons and there I have all icons. They are defined in Info.plist )
Is there anything I missed?

How can I disappear this post popup and automatically execute DidSelectPost() ?

$
0
0

I don't want to use the popup, because I use the share extension to pass to the "mother app" an url.

I would like to automatically, when you select the app at the moment to share something, it would do the functionallity of the DidSelectPost() method.

Can anyone help me ?

How to add Ads using Google Admobs in xamarin.android app?

$
0
0

I want to add Ads in my xamarin.android app using Google Admobs, Please help because I'm a newbie and thanks in advance

How to read from existing .db file?

$
0
0

I created questions.db file using DB Browser and want to read data from it in my Xamarin Forms application. That sounds pretty simple, right, but I'm 10+ hours stuck googling. Most answers just link to "Xamarin.Forms Local Databases" in microsoft docs.

Which explains nothing about the manually created database file, where to put it etc.

Some unofficial guides tell to put .db file to Resources/Assets folder for IOS/Droid, which seems right and I did.

I also added interfaces and [assembly: Dependency(typeof(DatabaseService))].... thing for android/ios, but failed. Everyone seems to use slightly different syntax, i haven't seen something for that in official docs, I'm completely lost.

Sorry for not posting any code, I'm not even sure which path to take, that's why I'm not diving into exact syntax right now.

Forms app hangs when calling .Result on an async request

$
0
0

I have created a cross-platform xamarin forms app (xamarin.forms version 4.5.0.495) and run the android app using Android 10.0 (Q) and a Pixel 2 Q 10.0 - API 29 emulator.

My xaml page contains this block:
<Entry Placeholder="please enter your search query" ClearButtonVisibility="WhileEditing" Keyboard="Text" ReturnType="Search" Completed="OnSearch" > </Entry>

The code in my xaml.cs file looks like this:

`
private async void OnSearch(object sender, EventArgs e)
{
string url = ...;
string result1 = await GetAsync(url);
string result2 = Task.Run(() => GetAsync(url)).Result;
string result3 = GetAsync(url).Result;
}

    private static async Task<string> GetAsync(string url)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

        using (HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync())
        using (Stream stream = response.GetResponseStream())
        using (StreamReader reader = new StreamReader(stream))
        {
            return await reader.ReadToEndAsync();
        }
    }

`

I have hard-coded the url for debugging purposes. Moreover I am not yet allowed to post links so I have replaced the url to wikipedia with '...'. When debugging the application result1 and result2 can be obtained, however, the app is stuck thereafter and result3 can not be retrieved.

The stack trace looks as follows:

`

0xFFFFFFFFFFFFFFFF in System.Threading.Monitor.Monitor_wait C#
0x31 in System.Threading.Monitor.ObjWait at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Threading/Monitor.cs:85,5 C#
0x11 in System.Threading.Monitor.Wait at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/monitor.cs:218,13    C#
0x3 in System.Threading.Monitor.Wait at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/monitor.cs:228,13 C#
0x109 in System.Threading.ManualResetEventSlim.Wait at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/shared/System/Threading/ManualResetEventSlim.cs:607,33  C#
0x30 in System.Threading.Tasks.Task.SpinThenBlockingWait at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2892,25 C#
0x6C in System.Threading.Tasks.Task.InternalWait at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:2832,21 C#
0x13 in System.Threading.Tasks.Task<string>.GetResultCore at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:490,31   C#
0x11 in System.Threading.Tasks.Task<string>.get_Result at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corert/src/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs:466,19  C#

`

It looks like there might be a deadlock.
I have searched the forum for "Monitor_wait" and found this this thread and bug report:

(I am not allowed to post links yet, I hope you can find these references:)

https://forums.xamarin.com/discussion/comment/189927#Comment_189927
and
github => bugzilla-archives/40/40228/bug

I guess that my finding is related to the bug above, which has been fixed in xamarin.forms version 2.2.0-pre4. Please bear with me, as I am new to Xamarin, maybe my setup is odd or I am doing something wrong. Any kind of input is appreciated,

best regards!

How can I achieve this using MVVM?

$
0
0

Hello All,
I am designing a Xamarin.Forms app and I am trying to follow the MVVM design pattern, but I am unsure what the correct way to proceed is in my particular situation.

There are two things I am unsure about. Consider the below.

I have got a ContentPage called "MainPage", which is made up of a XAML and a cs file, that contains two entries

<?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="XamarinForumTest.MainPage"
             BackgroundColor="LightGray">

    <StackLayout>
        <Entry x:Name="entryA"
               Text="Label1"/>
        <Entry x:Name="entryB"
               Text="Label2"
               Focused="entryB_Focused"/>
    </StackLayout>
</ContentPage>

I also have a ViewModel called MainPageViewModel.

I want to the user to be unable to edit entryB when entryA's text is "Select". The problem is that when I set IsEnabled of entryB to false the TextColor will be set to a dark grey/black colour which makes it invisible on a dark background.

A non MVVM solution to this problem is to create a field in code behind that indicates whether entryB should be in an enabled state. This field can be set in the code behind's OnAppearing() method. In the field's setter you can then change the text colour of the entry depending on what value is being assigned to the field. Finally you have to put a check in labelB's 'Focused' event that will just return so nothing happens.

    public partial class MainPage : ContentPage
    {
        bool isEntrybEnabled;

        bool IsEntrybEnabled
        {
            get { return isEntrybEnabled; }
            set
            {
                isEntrybEnabled = value;

                //Set the text color to something indicating that the entry is disabled
                entryB.TextColor = Color.Red;
            }
        }

        public MainPage()
        {
            InitializeComponent();
        }

        protected override void OnAppearing()
        {
            //Set whether entry B should be enabled
            this.IsEntrybEnabled = entryA.Text == "Select" ? false : true;
        }

        private void entryB_Focused(object sender, FocusEventArgs e)
        {
            Entry entry = (Entry)sender;
            entry.Unfocus();

            if (!this.IsEntrybEnabled)
            {
                return;
            }

            //Do business logic stuff here
        }
    }

Assuming the solution wasn't totally convoluted, which I believe it to be, how would I translate this into an MVVM pattern?
I could add a property for IsEntrybEnabled to my ViewModel and create another one that sets entryB's TextColor, but I am just not sure that's the best way forward as I am trying to keep as much UI related logic as I can in XAML and code behind.
Also, how can I separate the UI logic (Unfocus()) and the business logic that's meant to happen after?
Is it okay to have properties in you ViewModel whose only purpose is to manipulate the UI?

I am aware that using an Entry like this is probably not an ideal use case for it, but wonder what a possible solution could be nonetheless.

Thank you.

Is there a way to get a web page title from WKWebView

$
0
0

Hi, I need to get the page title of the current web page displayed in WKWebView. Is there a way to do this? Any help would be greatly appreciated. There only seems to be info out there for getting local html data.


VSforMac: Always building device specific builds

$
0
0

Hi all,
Strange one this, I have an iOS project that when no matter if Device specific builds is on or off, the app is always built in a device-builds/[device] folder.
I have even replaced the property groups for that configuration with another that works, but it still creates a device specific build.

The reason I want to switch this off is for UITesting, I want the build to go to a known folder that the UITest will use.

Any suggestions?

Thanks
John

Animated GIF Splash Screen using FFImageLoading

$
0
0

Hello,

I followed Microsoft Documentation to implement Splash Screen and it works very well.
I´m using FFimageLoading to display Gifs inside APP, and it works, but i don´t how to do it to play a Gif as Splash Screen...

Could you help me ?

Thanks in advance

google store error for aab bundle.

$
0
0

hello
I had just installed a clean installation for windows 10, and a fresh version of visual studio 2019.

When I try to archive with APK format i got rejected by password...
and then if I will try with .aab format bundle - it will accept the password - but an error on google store will say your new bundle is an old version code......
so the old version is 27 and the new is 29 also in manifast.xml...

so: archive .apk reject by password but .aab fail by code version......

prior to this error it was the fallowing error
Severity Code Description Project File Line Suppression State
Error Using ProGuard with the D8 DEX compiler is no longer supported.
Please set the code shrinker to r8 in the Visual Studio project property pages or edit the project file in a text editor and set the AndroidLinkTool MSBuild property to r8.

that i fixed by edit the project file

the google error



regards.

Splash screen gif

$
0
0

Since xamarin 4.4 is around, they support .gif with is great for animating the splash screen of our app. The thing that I cant figure out is: how to figure out when the animation in over, so I can preform a transition.

Things I tried

  1. Creating a timer for the time of the animation, but since every phone is diferent, I tested in on a pixel 3 and it was perfect. I tested it on an Iphone and is was looping 3 times.
  2. keeping track with a bool like this
  bool x = spashLogo.IsAnimationPlaying;

            if (x == false) {
                Debug.Write("ccc");
            }
  1. Going to a website and modifying the count of the gif to be 1

How can I bind text property of label to a sub/function value

$
0
0

Hi all,

I am very new to Xamarin, but very familiar with C#. What I am trying to do is get the value of sub routine in the cs file in my project and display it as the label text. Right now the routine is just returning some string value. The ultimate goal of this is to have the sub get the IP addy and display that value in the label text. I am trying to learn in little chunks, so getting the IP addy is a bit down the road.

I have been through a lot of iterations of this, nothing has worked so far, so what I have here might be very far from the mark:

From MainPage.xml:

        <Label
            x:Name="label3"
            Text="Some Text"
            />

From MainPage.xml.cs:

    private void SomeText(object sender, EventArgs e)
    {
        display = "Somemore Text";
        label3.Text = display;
    }

display is declared earlier in the MainPage,xml.cs file so that isn't causing an issue.

I have had bindings statements in and out, made the C# code above a function with a return value, made the sub public, etc. There are holes in the walls all over the house from banging my head against them.

Any hints on how to make this work would be greatly appreciated.

This is an app I am developing for learning how to create Android apps. I have a really usable app in mind for the company for which I work, but I need to know how to build apps before I jump into that project.

If someone can recommend a good Xamarin book, I would use that also. I prefer a physical book. I am old school that way.

Thanks bunches.

Bruce

Xamarin forms portable library with obfuscation .Net reactor

$
0
0

I am working on Xamarin forms project (with portable project)
I am trying to obfuscate the portable dll using .Net Reactor I hve done that using a batch file which is set as a post build event for the portable project and everything works fine (i.e the generated dll is obfuscated successfully )
here is the script code
"C:\Program Files (x86)\Eziriz.NET Reactor\dotNET_Reactor.exe" -project "reactor.nrproj" -file "myProject.dll"
copy "myProject_Secure\myProject.dll" "myProject.dll"

the problem is when I build the droid project I got the following error
Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Windows, Version=255.255.255.255, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Windows.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters) in /Users/builder/data/lanes/5147/c2a33d8e/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:line 220
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver) myProject.Droid

I am sure that problem comes from the obfuscation because everything works fine without the obfuscation

any help in this problem ?
does anybody work with .Net reactor to obfuscate Xamarin forms projects?

BTW, I have un-check all the quick settings of the .Net reactor and the problem is still shows up

GIF on splash screen for both Android and iOS app

$
0
0

Dear All,

Greetings!

In our app we have a requirement to display the GIF animated image on the splash screen for both Android and iOS apps.

We have found some solution for Android. But, looking out for the iOS solution.

Help is appreciated..

thanks

Regards
PG


Xamarin Android Animated Splash Screen

$
0
0

Hi , I am trying to add Animated Splash in my xamarin Android App , so I added a new activity (Splash Activity) and created a layout where I am displaying a GIF image but after adding this I am getting a black screen after Animation for 2 to 3 seconds. as I observe my Main class is taking time to load and that is why I am getting black screen the same thing is not happening if I directly add a theme (static image).

Can anyone please suggest me how can I resolve this or at-least suggest me any better approach to implement Animated Splash in Xamarin Android project. Thanks.

ContentView controls not working - why?

$
0
0

I am trying to create a control using a ContentView, and I don't understand why my controls (button and entry for testing) are not clickable.

Here is the XAML for the control:

<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:E2Mobile="clr-namespace:E2Mobile"
             mc:Ignorable="d"
             x:Class="E2Mobile.Selector"
             IsVisible="True">
  <ContentView.Content>
        <Frame x:Name="SelectorFrame" Padding="0" CornerRadius="0" IsClippedToBounds="True" BackgroundColor="Red" Margin="0" IsVisible="False">
            <StackLayout Orientation="Vertical">
                <Button x:Name="TheButton" Clicked="ButtonClick" Text="ClickMe" IsEnabled="True"></Button>
                <Entry x:Name="myentry" Placeholder="asdf"></Entry>
            </StackLayout>
        </Frame>
    </ContentView.Content>
</ContentView>

And the code for the control:

using System;
using System.Collections.Generic;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace E2Mobile
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Selector : ContentView
    {
        public Selector()
        {
            InitializeComponent();
        }

        public void ButtonClick(object sender, EventArgs e)
        {
            TheButton.Text = "clicked";
        }

        public void Show(VisualElement callingElement = null)
        {
            this.IsVisible = true;
            SelectorFrame.IsVisible = true;
        }
    }
}

When the page the control is on calls Show(), the UI appears (I also ensure no other elements are covering the control), but neither the button nor the Entry respond to any tap at all - the button doesn't highlight, tapping the Entry does not bring up the keyboard.

I know I'm missing something simple, but it's eluding me. Any help is appreciated

Thanks!

HTML-content in ViewCell

$
0
0

Hello everyone!

I am trying to display a label with TextType HTML. When I put the app to background or when I bring it back to foreground I get the following crash:

Objective-C exception thrown.  Name: NSInternalInconsistencyException Reason: unexpected start state

I've had this problem before but didn't manage to solve it. I have tried a few different nugets for HTML-cells, but get the same crash.

Has anyone had this problem and figured out how to solve it?

I am also wondering if there is any way of supporting more HTML/CSS on Android. With my test project on iOS (before the crash) I get all the styling defined. But with Android I am just getting basic (bold, cursive etc) styling.

Thank you,
Daniel

Flags attributes over the call

$
0
0

Can somebody explain me the functionality of intent.AddFlags(ActivityFlags.NoUserAction); ?

I need desable the number keyboard and then also to be invisible the number of call destination...

Thank you so much !!

Error APT1000: Found tag id where item is expected (APT1000) (SWLog.Android)

$
0
0

Trying to update to android api 30.
I get Error APT1000: Found tag id where item is expected (APT1000) (SWLog.Android)

all in styles.xml
<?xml version="1.0" encoding="utf-8"?>


any ideas how to resolve?

Viewing all 204402 articles
Browse latest View live


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