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

Xamarin Forms WebView, can I see if the user authenticates to a site inside the webview?

$
0
0

I got an app that only contains a webview, pointing to a site with a login screen. The users of the app should be able to get notifications, but only if they are authenticated (logged in to the site in the webview). Is there any way to tell if the user of the app is authenticated to the website in the webView? Any way for the app to know if the user clicks the login button in the webview?

I know that we can override OnReceivedHttpAuthRequest in a custom renderer, but this is not triggered by the login screen of this website so it doesn't work in this case.

Any suggestions?


Dynamic Grid Control (segmented button)

$
0
0

hi all,

i am trying to create a control that will allow a grid to be created dynamically depending on the number of rows and columns (number of columns will change per row) defied in a data store.

using a single grid and trying to span rows is proving difficult so i have decided to create a grid, each row in the parent grid will have a new grid with a single row and multiple columns.

CODE

public class SegmentedButtonGroup : Grid
    {
        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();

            ReCreateGridLayout();
        }

        private void OnItemSourceChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            ReCreateGridLayout();
        }

        private int ColumnCountRequired = 5;
        private int RowCountRequired = 5;   

        private void ReCreateGridLayout()
        {
            // loop through each row that is required on the grid
            for (int currentRow = 0; currentRow < RowCountRequired ; currentRow++)
            {
                // create a new grid
                var newGrid = new Grid();
                newGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });

                // loop through each column that is required in the current row
                for (int currentColumn = 0; currentColumn < ColumnCountRequired; currentColumn++)
                {
                    newGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

                    // create a label
                    var label = new Label
                    {
                        Text = string.Format("{0}:{1}", currentRow, currentColumn),
                        HorizontalTextAlignment = TextAlignment.Center,
                        VerticalTextAlignment = TextAlignment.Center
                    };

                    // create a frame and add the label to it
                    var frame = new Frame
                    {
                        BackgroundColor = Color.Transparent,
                        OutlineColor = Color.Blue,                        
                        Content = label,
                        HasShadow = true,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        VerticalOptions = LayoutOptions.FillAndExpand
                    };

                    // add the frame to the cuurent row / column in the newly created grid
                    newGrid.Children.Add(frame, currentColumn, currentRow); 
                }

                // add the newely created grid to the parent grid
                Children.Add(newGrid, 0, currentRow);

                // reduce the number of columns on the next row to simulate row span       
                ColumnCountRequired = ColumnCountRequired - 1;
            }
        }
    }

XAML

    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:vm="clr-namespace:Smdc.SegmentedButtonExample;assembly=Smdc.SegmentedButtonExample"
                 xmlns:controls="clr-namespace:Smdc.Controls.SegmentedButton.Version2;assembly=Smdc.Controls.SegmentedButton"
                 x:Class="Smdc.SegmentedButtonExample.Views.DataEntryView2">


        <ContentPage.BindingContext>
            <vm:DatEntryViewModel2 />
        </ContentPage.BindingContext>


            <controls:SegmentedButtonGroup Padding="20,20,20,20">
            </controls:SegmentedButtonGroup>

    </ContentPage>

the grid width and column widths are working as expected but i am having problems with my row heights along with the spacing between rows. please see attached screen capture.

this control is to form the basis of a segmented button and so i would like all the rows to be the same height with minimal and consistent space between the rows.

any help would be appreciated.

thanks,

jas

About Message Center Send Exception

$
0
0

When I send a message from my CustomWebView in droid side, I get an exception;

what may occur the reason?

StackTrace;

" at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0008e] in :0 \n at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0001f] in :0 \n at Android.Widget.TextView.set_TextFormatted (Java.Lang.ICharSequence value) [0x00029] in <11f101b564894ca7af6c482ddc51c698>:0 \n at Android.Widget.TextView.set_Text (System.String value) [0x0000d] in <11f101b564894ca7af6c482ddc51c698>:0 \n at Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer.UpdateText () [0x000f3] in D:\a\1\s\Xamarin.Forms.Platform.Android\FastRenderers\LabelRenderer.cs:407 \n at Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00123] in D:\a\1\s\Xamarin.Forms.Platform.Android\FastRenderers\LabelRenderer.cs:288 \n at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)\n at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:229 \n at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:353 \n at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:461 \n at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397 \n at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:334 \n at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:311 \n at Xamarin.Forms.Label.set_Text (System.String value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Label.cs:139 \n at XamApp.Views.WebBrowserPage.<.ctor>b__0_1 (System.Object sender, System.String str) [0x00052] in C:\Users\ErdoganPc\source\repos\XamApp\XamApp\XamApp\Views\WebBrowserPage.xaml.cs:64 \n at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)\n at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 \n --- End of managed Android.Util.AndroidRuntimeException stack trace ---\nandroid.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.\n\tat android.view.ViewRootImpl.checkThread(ViewRootImpl.java:7753)\n\tat android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1225)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.widget.RelativeLayout.requestLayout(RelativeLayout.java:360)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.widget.RelativeLayout.requestLayout(RelativeLayout.java:360)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.view.View.requestLayout(View.java:23093)\n\tat android.widget.TextView.checkForRelayout(TextView.java:8908)\n\tat android.widget.TextView.setText(TextView.java:5730)\n\tat android.widget.TextView.setText(TextView.java:5571)\n\tat android.widget.TextView.setText(TextView.java:5528)\n\tat crc6446ba3e777276519d.CustomActionWebView_ActionSelectInterface.n_callback(Native Method)\n\tat crc6446ba3e777276519d.CustomActionWebView_ActionSelectInterface.callback(CustomActionWebView_ActionSelectInterface.java:37)\n\tat android.os.MessageQueue.nativePollOnce(Native Method)\n\tat android.os.MessageQueue.next(MessageQueue.java:326)\n\tat android.os.Looper.loop(Looper.java:160)\n\tat android.os.HandlerThread.run(HandlerThread.java:65)\n"

Google ANR Analyzer for Xamarin apps

$
0
0

Hi,

As you know that the current Google ANT=R available on Google Play Console is as of no use when developing Xamarin apps because it doesn't tell where is the issue, which page and what control?

I also tried Firebase but it's the same and Microsoft App Center don't have this feature yet as confirmed by the team.

Is there any good analyzer to use with Xamarin to identify the ANR issue?

Thanks,
Jassim

UWP - Immediate crash in release mode

$
0
0

I have a forms solution, it runs fine in debug but crashes immediately in release mode, it doesn’t even get to my MainPage constructor:

    Unhandled exception at 0x54D62408 (Windows.UI.Xaml.dll) in SmartCart.UWP.exe: 0xC000027B: An application-internal exception has occurred (parameters: 0x0D6594E8, 0x00000003).
    Unhandled exception at 0x76341104 (combase.dll) in SmartCart.UWP.exe: 0xC0000602:  A fail fast exception occurred. Exception handlers will not be invoked and the process will be terminated immediately.
    STATUS_STACK_BUFFER_OVERRUN encountered
    The program '[11592] SmartCart.UWP.exe' has exited with code -1073740791 (0xc0000409).

When I build everything in release except for my UWP project the project will run.

Is this an issue with forms? Has anyone build and run UWP Forms in release mode?

Monogame as a view for Xamarin.Forms?

$
0
0

I'm developing an app that should have both Xamarin.Forms view and Monogame view simultaneously. Is there a way to embed Monogame into Xamarin.Forms app in 2020?I was trying to search the forum, but all older questions like this went unanswered. Thanks!

Deserialize a json

$
0
0

Hello Developers,

I have a json and i want to deserialize json to object, below i attach a json file

Android Device manager , i cannot open device. i got this error

$
0
0

Android Device manager , i cannot open device. i got this error

please help me


How to get twitter feeds from multiple users screenname using LinqToTwitter ,

$
0
0

How to get twitter feeds from multiple users screenname using LinqToTwitter .
means i want get 30 items list from 30 sceenname of single tweet from each.

here my code

public async Task InitTweetsAsync()
{

        var auth = new ApplicationOnlyAuthorizer()
        {
            CredentialStore = new InMemoryCredentialStore
            {
                // Please use this link to create a new app in Twitter
                // https://apps.twitter.com/app/new
                // so you can get ConsumerKey and ConsumerSecret
                ConsumerKey = "T**********************",
                ConsumerSecret = "*************************************",
                    },
        };

        await auth.AuthorizeAsync();

        var ctx = new TwitterContext(auth);

        var tweets = await (from tweet  in ctx.Status where tweet.Type == StatusType.Oembed
                   && tweet.ScreenName == "keboola"
                   && tweet.Count == 30
             select tweet)
            .ToListAsync();




        Tweets = (from tweet 
                  in tweets
                  select new Tweet
                  {
                      StatusID = tweet.StatusID,
                      ScreenName = tweet.User.ScreenNameResponse,
                      Text = tweet.Text,
                      ImageUrl = tweet.User.ProfileImageUrl,
                      MediaUrl = tweet?.Entities?.MediaEntities?.FirstOrDefault()?.MediaUrl
                  })
            .ToList();

      }

sqlite concat string issue

$
0
0

I need to add string to Order Number. I added like this. But i am getting only order number without string. I tried it with || also its return 0.

var data = conn.Query<Orders>("SELECT DateTime,('ORD-' + OrderId) AS OrderId, Total FROM Orders");

Task throws System.Reflection.TargetInvocationException

$
0
0

Hi,

I am getting this error:

System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'

Here is how I am getting it..

In my Click event, I am doing:

StackLayoutSignin.IsVisible = false;
BusyIndicatorSignin.IsVisible = true;
await Task.Run(SigninUser);

the SigninUser is:

async void SigninUser()
{
    var salt = await PasswordHash.GetPasswordSalt(TextBoxSigninEmailAddress.Text);
    ....................
    ....................
    ....................
    ....................
}

and the error occurs on this line:

var salt = await PasswordHash.GetPasswordSalt(TextBoxSigninEmailAddress.Text);

My GetPasswordSalt is here:

public static async Task<Tuple<string, string>> GetPasswordSalt(string email_address)
{
    // var client = new HttpClient();

    using (var client = new HttpClient())
    {
        client.BaseAddress = new Uri("https://www.my.com/salt.php");

        var content = new FormUrlEncodedContent(new[]
        {
            new KeyValuePair<string, string>("email", email_address)
        });

        var response = await client.PostAsync("https://www.my.com/salt.php", content);

        var result = await response.Content.ReadAsStringAsync();

        if (!String.IsNullOrWhiteSpace(result))
        {
            dynamic data = JsonConvert.DeserializeObject(result);

            salt_result = data[0].result.ToString();
            password_salt = data[0].password_salt.ToString();
        }
        else
        {
            password_salt = "X";
        }

        return new Tuple<string, string>(salt_result, password_salt);
    }
}

kindly help...

Thanks,
Jassim

Sliding Panel like native Google/Apple Maps

$
0
0

Hello,

I am looking for a sliding panel that slides up from bottom and is draggable, similar to what native maps provide on iOS and Android platforms. I would really appreciate if someone can help. I tried DKSlidingPanel but its very hard to customize it (since it has extra UI bits that we don't need).

Thanks

AP

ControlTemplate binding not refreshing when property changes

$
0
0

I am having an issue binding to a label. On initial load of the page the label gets set correctly but if I change the binding property the label does not change.

In my ControlTemplate that is defined in the App.xaml I have a label definded like:

<StackLayout x:Name="bottomLayout" Orientation="Vertical" VerticalOptions="EndAndExpand" BackgroundColor="White"  Grid.Row="2"
                                 Padding="0" Spacing="0" Margin="0">
                        <Label x:Name="lblConnectionStatus" TextColor="Black" FontSize="Small" Text="{TemplateBinding Parent.ConnectionStatus, Mode=TwoWay}"
                               VerticalOptions="CenterAndExpand"`` 
                               HorizontalOptions="CenterAndExpand" />
                    </StackLayout>

Then I have my property defined like this on the page:
private string _ConnectionStatus;
public string ConnectionStatus { get { return _ConnectionStatus; } set { _ConnectionStatus = value; OnPropertyChanged(); } }

For whatever reason the label that is defined in the template won't change if the property changes. For testing I added another label directly in the page itself and did binding to this same property and that will change like it is suppose to.

Put item in Label from firebase

$
0
0

With this i fill a Listview from a Firebase database with Name

`

protected async override void OnAppearing()
{
await Task.Delay(2000);

        base.OnAppearing();
        var allPersons = await firebaseHelper.GetAllPersons();
        lstPersons.ItemsSource = allPersons;

        lstPersons.ScrollTo(allPersons.LastOrDefault(), ScrollToPosition.End, false);

    }

`

There is always 1 item in the database , i want to fill a Label with the name txtCheck

txtCheck.Text="{Binding Name}"

But this is only working inside the listview , and the "Label is outside the listview and then it is not working ?

how to import an object in urhosharp

$
0
0

Hello,
I made made progress in my planetarium project: I know how to add urhosharp in my xamarin.forms project and how to show lines and write text. But I need to receive a boost.

The purpose is to make a planetarium. The user sees stars and can click on a star to select it and get informations.
I made a 3D scene with blender and python scripting with white filled circles around a sphere (500 stars are at the good position, facing the center). The light and the camera are in the center of the scene (see picture). I can render it.

Next, I need to import the objects in my xamarin.forms project.

These are few questions. If an Urhosharp expert could give me few indications, it could be great.

  1. I need to use Assetimport to convert my scene. Can I convert a full node with all the circles in it. Is there any step by step documentation ?
  2. what will I get? a xml file? 500 xml files? a mdl file?
  3. where should I copy these files to import them in my project?
  4. how can I import them in my code, what is the path?
  5. how can I import in my project a blender made material?
    I made python scripting in blender to draw the sky.
  6. would it be a better (faster or easier) solution to draw the sky in C# in the app?
  7. would it be a better (faster or easier) solution to draw the sky in urho editor with angelscript?

Thank you for your help and your advices


After closing the page execute the function

$
0
0

Hi
The pop up page is open window
How do I execute another function on the previous page after closing the page?

Error: unexpected element found in

$
0
0

Suddenly I get this build error in VS 2019 but not in VS 2017 when I build my Android project:
unexpected element <receiver> found in <manifest>

And this is what those lines look like:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.0.26" android:versionCode="148" package="ca.levitica.livedispatch.staging" android:installLocation="auto">
  <!-- Other stuff -->
  <receiver android:name=".BootReceiver" android:enabled="true">
    <intent-filter>
      <action android:name="android.intent.action.BOOT_COMPLETED"></action>
    </intent-filter>
  </receiver>
  <!-- Other stuff -->
</manifest>

What can I do? Thanks!

set icon in Stepper

local notification

$
0
0

Hi guys, I've been trying to implement code from "xamarin microsoft page" regarding the local notification.
I tried to post the link here, but the this page doesnt let me saying I need to be around for a little while.
The code that Ive tried, given by their team work succesfully.
but the notification will be triggered right after we tap the "button".
I want to make it, to notify the user by following the dateTime value.
And Im developping a cross platform application.

    result1 = 20000 + mEntry; 
            result2 = result1 / avgEntry;
            DateTime endDateTime = DateTime.Now.AddDays(result2);
            outputKm.Text = endDateTime.ToString("dd-MM-yyyy"); 

So, when we press the remind me button, it will take the date from endDateTime and will notify the user, based on the date of endDateTime.
I know I need to change it somwhere in the code given by the microsoft team, but I have no idea, since I am new with mobile development.
Thank you guys.

Preventing OverScroll on the ScrollView

$
0
0

I can't seem to find a property to handle this, but is it possible to prevent the user from being able to pull a ScrollView down?

Viewing all 77050 articles
Browse latest View live


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