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

camera stream stop after send image by camera input file webview

$
0
0

i have app for video call, in app i am using webview for video call between two users. 2 users can aslo share file with each other via from gallery or camera.
Now the issue i am facing when both users are in between call and one user send image from camera, the camera that is already running for video get stopped. These are errors i am getting

07-02 14:47:06.115 I/CameraManagerGlobal( 3656): Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_IDLE for client com.kihmobile.kih API Level 2
07-02 14:47:06.175 I/CameraManagerGlobal( 3656): Camera 1 facing CAMERA_FACING_FRONT state now CAMERA_STATE_CLOSED for client com.kihmobile.kih API Level 2
07-02 14:47:06.182 E/CameraCaptureSession( 3656): Session 0: Exception while stopping repeating: 
07-02 14:47:06.182 E/CameraCaptureSession( 3656): android.hardware.camera2.CameraAccessException: CAMERA_DISCONNECTED (2): cancelRequest:473: Camera device no longer alive
07-02 14:47:06.182 E/CameraCaptureSession( 3656):   at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:1127)
07-02 14:47:06.182 E/CameraCaptureSession( 3656):   at android.hardware.camera2.impl.ICameraDeviceUserWrapper.cancelRequest(ICameraDeviceUserWrapper.java:97)
07-02 14:47:06.182 E/CameraCaptureSession( 3656):   at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:1151)
07-02 14:47:06.182 E/CameraCaptureSession( 3656):   at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:526)
07-02 14:47:06.182 E/CameraCaptureSession( 3656):   at 

android.hardware.camera2.impl.CameraCaptureSessionImpl$2.onDisconnected(CameraCaptureSessionImpl.java:737)

this is my webview code in xamarin

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Android.Annotation;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Provider;
using Android.Runtime;
using Android.Support.V4.Content;
using Android.Views;
using Android.Webkit;
using Android.Widget;
using Java.Interop;
using Java.IO;
using OnlineKIHStore.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(OnlineKIHStore.MyWebView), typeof(MyWebViewRenderer))]

namespace OnlineKIHStore.Droid
{
    public class MyWebViewRenderer : WebViewRenderer
    {
        MainActivity mContext;
        public MyWebViewRenderer(Context context) : base(context)
        {
            this.mContext = context as MainActivity;
        }
        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)
        {
            base.OnElementChanged(e);

            var oldWebView = e.OldElement as MyWebView;
            if (oldWebView != null)
                oldWebView.EvaluateJavascript = null;

            var newWebView = e.NewElement as MyWebView;
            if (newWebView != null)
                newWebView.EvaluateJavascript = async (js) =>
                {

                    ManualResetEvent reset = new ManualResetEvent(false);
                    var response = "";
                    Device.BeginInvokeOnMainThread(() =>
                    {
                       // System.Diagnostics.Debug.WriteLine("Javascript Send: " + js);

                        Control?.EvaluateJavascript(js, new JavascriptCallback((r) => { response = r; reset.Set(); }));

                    });
                    await Task.Run(() => { reset.WaitOne(); });
                    if (response == "null")
                        response = string.Empty;

                    return response;
                };

            if (Control != null && e.NewElement != null)
            {
                InitializeCommands((MyWebView)e.NewElement);
                //SetupControl();
            }
            Control.Settings.JavaScriptEnabled = true;
            Control.Settings.MediaPlaybackRequiresUserGesture = false;
            Control.ClearCache(true);
            Control.SetWebViewClient(new WebViewClientAuthentication());
            Control.SetWebChromeClient(new MyWebClient(mContext));
            Control.Settings.DomStorageEnabled = true;
            Control.Settings.AllowUniversalAccessFromFileURLs = true;
            Control.Settings.AllowFileAccess = true;
            global::Android.Webkit.WebView.SetWebContentsDebuggingEnabled(true);







        }
        private void InitializeCommands(MyWebView element)
        {

            element.RefreshCommand = new Command(() =>
            {
                Control?.Reload();
            });

            element.GoBackCommand = new Command(() =>
            {
                var ctrl = Control;
                if (ctrl == null)
                    return;

                if (ctrl.CanGoBack())
                    ctrl.GoBack();
            });

            element.CanGoBackFunction = () =>
            {
                var ctrl = Control;
                if (ctrl == null)
                    return false;

                return ctrl.CanGoBack();
            };

            // This allows you to show a file chooser dialog from the WebView

        }
        public class WebViewClientAuthentication : WebViewClient
        {
            public override void OnReceivedSslError(Android.Webkit.WebView view, SslErrorHandler handler, Android.Net.Http.SslError error)
            {
                handler.Proceed();
            }
        }

        public class MyWebClient : WebChromeClient
        {
            private static int filechooser = 1;
            private IValueCallback message;
            MainActivity mContext;
            private static int cameraCode=11;

            public static Android.Net.Uri myImageUri { get; private set; }

            public MyWebClient(MainActivity context)
            {
                this.mContext = context;
            }
            private Android.Net.Uri getFileUri()
            {
                Android.Net.Uri imageUri = null;
                string path = getFilePath();
                File file = new File(path);
                if (Build.VERSION.SdkInt >= BuildVersionCodes.N)
                {
                    try
                    {
                        imageUri = FileProvider.GetUriForFile(this.mContext, $"{mContext.ApplicationInfo.PackageName}.fileprovider", file);
                    }
                    catch (Exception e)
                    {

                    }

                }
                else
                {
                    imageUri = Android.Net.Uri.FromFile(file);
                }
                return imageUri;
            }

            private string getFilePath()
            {
                File externalDataDir = Android.OS.Environment
                        .GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim);
                File cameraDataDir = new File(externalDataDir.AbsolutePath
                        + File.Separator + "Images");
                cameraDataDir.Mkdirs();
                string mCameraFilePath = cameraDataDir.AbsolutePath
                        + File.Separator + "send_new_image.jpg";

                return mCameraFilePath;
            }
            [Export]
            [JavascriptInterface]
            private Intent createCameraIntent()
            {
                Intent cameraIntent = new Intent(MediaStore.ActionImageCapture);

                //Intent cameraIntent = new Intent(MediaStore.ActionImageCapture);
               myImageUri = getFileUri();
                //cameraIntent.PutExtra(MediaStore.Images.Media.InterfaceConsts.Orientation, 0);
                //cameraIntent.PutExtra(MediaStore.ExtraOutput, myImageUri);
                return cameraIntent;
            }
            public override bool OnShowFileChooser(Android.Webkit.WebView webView, IValueCallback filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)

            {
                //    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this.mContext);

                //    using (dialogBuilder = new AlertDialog.Builder(this.mContext))
                //    {
                //        dialogBuilder.SetTitle("Upload Image");
                //        dialogBuilder.SetPositiveButton("Choose from Library", delegate
                //        {
                //            Intent chooserIntent = fileChooserParams.CreateIntent();
                //            chooserIntent.SetType("image/*");
                //            this.mContext.StartActivity(Intent.CreateChooser(chooserIntent, "Select Picture"), 1, OnActivityResult);
                //        }

                //        dialogBuilder.SetNegativeButton("Cancel", delegate
                //        {
                //            dialogBuilder.Dispose();
                //        });
                //    }
                AlertDialog.Builder alertDiag = new AlertDialog.Builder(this.mContext);
                alertDiag.SetTitle("Confirm delete");
                alertDiag.SetCancelable(false);
                alertDiag.SetMessage("Once deleted the move cannot be undone");
                alertDiag.SetPositiveButton("Gallery", (senderAlert, args) =>
                {
                    this.message = filePathCallback;
                    Intent chooserIntent = fileChooserParams.CreateIntent();
                    chooserIntent.AddCategory(Intent.CategoryOpenable);

                    this.mContext.StartActivity(Intent.CreateChooser(chooserIntent, "File Chooser"), filechooser, this.OnActivityResult);


                });
                alertDiag.SetNegativeButton("Camera", (senderAlert, args) =>
                {
                    this.message = filePathCallback;
                    mContext.StartActivity(createCameraIntent(), cameraCode, this.OnActivityResult);

                });
                Dialog diag = alertDiag.Create();
                diag.Show();



                //this.message = filePathCallback;
                //Intent chooserIntent = fileChooserParams.CreateIntent();
                //chooserIntent.AddCategory(Intent.CategoryOpenable);

                //this.mContext.StartActivity(Intent.CreateChooser(chooserIntent, "File Chooser"), filechooser, this.OnActivityResult);
                return true;
            }
            private void OnActivityResult(int requestCode, Result resultCode, Intent data)
            {

                if (resultCode != Android.App.Result.Ok)
                {
                    this.message.OnReceiveValue(null);

                    return;
                }
                //if (data != null)
                //{
                    if (requestCode == MyWebClient.cameraCode)
                    {
                        if (null == this.message)
                        {
                            return;
                        }

                        try
                        {
                            Android.Net.Uri[] uris = new Android.Net.Uri[1];
                            uris[0] = MyWebClient.myImageUri;
                            this.message.OnReceiveValue(uris);
                        }
                        catch (Exception ex)
                        {

                            throw ex;
                        }
                        this.message = null;
                    }

                   else if (requestCode == filechooser)
                    {
                        if (null == this.message)
                        {
                            return;
                        }

                        try
                        {
                            this.message.OnReceiveValue(WebChromeClient.FileChooserParams.ParseResult((int)resultCode, data));

                        }
                        catch (Exception)
                        {

                            throw;
                        }
                        this.message = null;
                    }
                //}
            }
            [TargetApi(Value = 21)]
            public override void OnPermissionRequest(PermissionRequest request)
            {

                mContext.RunOnUiThread(() =>
                {
                    request.Grant(request.GetResources());

                });

            }
        }
        internal class JavascriptCallback : Java.Lang.Object, IValueCallback
        {
            public JavascriptCallback(Action<string> callback)
            {
                _callback = callback;
            }

            private Action<string> _callback;
            public void OnReceiveValue(Java.Lang.Object value)
            {
                //System.Diagnostics.Debug.WriteLine("Javascript Return: " + Convert.ToString(value));
                _callback?.Invoke(Convert.ToString(value));
            }
        }

    }
}

i just want to know how i can resume camera in video call after user send image from camera using input file...?

here are some picture how app looks like

this is running video call between two users and both users camera are open


android user where he can chat and send file via gallery or camera


now here when android user click on camera, camera does open to capture image, but camera that is already running for video call get stop


Xamarin Forms Webview doesn't show the tradingview widget.

$
0
0

Hi all,

I use a widget from tradingview site. I would like to make this implementation using xamarin forms webview. However i can't make it works. It just doesn't appear the widget at all.

The same piece of code woks correctly on a browser.
In the html code there is a script tag which the source file is from external resources(from their site).
So i would like to ask if the webview can load javascript resources from the web.

Any help will be appreciated.

Thanks in advance!

I would copy&paste the code but the forum doesn't allow me because every time i paste the code a captcha appear to check if i am human . When i click the check button the whole text disappeared. I try to post code like an answer of this question.

Xamrin form issue with HTTPS request

$
0
0

I have created an application in Xamrin forms with Visual studio 2017 Professional and Visual studio 2019 cumulative addition.

Problem is that app works fine with HTTP request, but in case of HTTPS request i have got time out every time with visual studio 2017 & with visual studio 2019 i have observed sometime getting response of request and sometime app not able to hit HTTPS request.

I have same code to call API. I am able to post WEB API with Postman every time successfully.

        HttpStatusCode = HttpStatusCode.Unused;
        HttpStatusCodeDescription = String.Empty;

        var response = default(TResp);
        XStatusCode = null;

        HttpWebRequest webRequest = null;
        HttpWebResponse webResponse = null;

        webRequest = (HttpWebRequest)WebRequest.Create(mServiceUrl + serviceName);

        webRequest.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(userName + ":" + password)));

        webRequest.Method = "POST";



        var reqData = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(request));

        webRequest.ContentLength = reqData.Length;
        webRequest.ContentType = "application/json; charset=utf-8";
         using (var reqStream = webRequest.GetRequestStream())
            reqStream.Write(reqData, 0, reqData.Length);

        try
        {
            using (webResponse = (HttpWebResponse)webRequest.GetResponse())
            {
                if (typeof(TResp) != typeof(object))
                {
                    using (var respStream = webResponse.GetResponseStream())
                    {
                        var reader = new StreamReader(respStream);
                        string result = reader.ReadToEnd();
                        response = JsonConvert.DeserializeObject<TResp>(result);
                    }
                }

                HttpStatusCode = webResponse.StatusCode;
                HttpStatusCodeDescription = webResponse.StatusDescription;
            }
        }
        catch (WebException ex)
        {
            webResponse = (HttpWebResponse)ex.Response;
            if (webResponse != null)
            {
                HttpStatusCode = ((HttpWebResponse)webResponse).StatusCode;
                HttpStatusCodeDescription = ((HttpWebResponse)webResponse).StatusDescription;
                if (webResponse.Headers["X-StatusCode"] != null)
                {
                    XStatusCode = int.Parse(webResponse.Headers["X-StatusCode"]);
                    if (webResponse.ContentLength > 0)
                    {
                        if (typeof(TResp) != typeof(object))
                        {
                            using (var respStream = webResponse.GetResponseStream())
                            {
                                var reader = new StreamReader(respStream);
                                string result = reader.ReadToEnd();
                                response = JsonConvert.DeserializeObject<TResp>(result);
                            }
                        }
                    }
                }
                webResponse.Close();
            }
        }

        return response;

Tried out with Http Client also getting same result

HttpStatusCode = HttpStatusCode.Unused;
HttpStatusCodeDescription = String.Empty;

        var result = default(TResp);
        XStatusCode = null;




        try
        {
            var client = new HttpClient();
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes(userName + ":" + password)));

            var json = JsonConvert.SerializeObject(request);
            HttpContent content = new StringContent(json);
            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var response = await client.PostAsync(mServiceUrl + serviceName, content);


            if (response.IsSuccessStatusCode)
            {
                result = JsonConvert.DeserializeObject<TResp>(response.Content.ToString());
            }

        }
        catch (WebException ex)
        {
            var webResponse = (HttpWebResponse)ex.Response;
            if (webResponse != null)
            {
                HttpStatusCode = ((HttpWebResponse)webResponse).StatusCode;
                HttpStatusCodeDescription = ((HttpWebResponse)webResponse).StatusDescription;
                if (webResponse.Headers["X-StatusCode"] != null)
                {
                    XStatusCode = int.Parse(webResponse.Headers["X-StatusCode"]);
                    if (webResponse.ContentLength > 0)
                    {
                        if (typeof(TResp) != typeof(object))
                        {
                            using (var respStream = webResponse.GetResponseStream())
                            {
                                var reader = new StreamReader(respStream);
                                string resulttmp = reader.ReadToEnd();
                                result = JsonConvert.DeserializeObject<TResp>(resulttmp);
                            }
                        }
                    }
                }
                webResponse.Close();
            }
        }



        return result;

PCL package

Android package

Cut off 1 corner in Collectionview

$
0
0

How do i make this in a Collectionview , 1 corner is cut off and not round with cornerradius

Editor inside Scrollview not scrolling.

$
0
0

I have an editor control inside a StackLayout which is inside a ScrollView. I can scroll all the controls but when I go into an editor control if the text superpasses the editor's height I cannot scroll into the previously added text. So if the line goes out of the visible part of the editor I cannot go back to it, the only way is to erase the whole text and write something up again. So basically trying to scroll inside the editor results in scrolling out the controls inside the scrollview but I just want to scroll inside the editor. By the way editors are added to the stacklayout dynamically.

<ScrollView>
                <StackLayout x:Name="content" Orientation="Vertical"></StackLayout>
            </ScrollView>

Any suggestions?

Thank you.

In-App camera function

$
0
0

Hi all,

My app uses the standard camera for taking pictures (iOS and Android), but since I want to change the behaviour of the camera itself I need to create an in-app camera. I took a look at the ConferenceVision example, which seems pretty good for me: https://github.com/microsoft/ConferenceVision . The user in my my app has to take a picture, view it, and if the picture is good enough send it to an API.

Problem is that I cannot get it working in my app. It doesn't show the camera permissions somehow (it doesn't ask for any permissions), which causes the app to not show the camera.

I made a simple demo in the attachment, I hope someone can help me with this.

PopToRootAsync with Modal

$
0
0

Navigation.PopToRootAsync() throws and exception when the page on top of the stack is a modal. Is there any work around for this?

Archiving iOS app in VSWin and getting a path, file name too long error

$
0
0

I am trying to create an archive (ipa file) for Apple store submission and keep getting this error that the path or file name is too long. I can't easily change out my windows sign in folder directory nor my local app data folder. What is the workaround for this? Silly that this is even an issue in 2020 with Windows 10.


Path too long Xamarin iOS Distribute

$
0
0

Help me pls i can't distribute because my paths are too long.
I tried to change them but it didn't help.
I'm really out of ideas.
That's the error:
Unable to copy file "C:\Users\cunnin\AppData\Local\Xamarin\MonoTouch\Archives\2019-10-18\ZAsetMobile.iOS 10-18-19 10.22 AM.xcarchive\mSYMs\ZAsetMobile.iOS.app.mSYM\b5883af4fb74101e3ffa838fae7f2094\Microsoft.Extensions.DependencyInjection.Abstractions.dll.msym" to "obj\iPhone\AppStore\archives\ZAsetMobile.iOS 10-18-19 10.22 AM.xcarchive\mSYMs\ZAsetMobile.iOS.app.mSYM\b5883af4fb74101e3ffa838fae7f2094\Microsoft.Extensions.DependencyInjection.Abstractions.dll.msym". The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

I don't finds a way to change the path in xamarin settings.

VS2019 the specified path file name or both are too long error !

$
0
0

Hi everyone !

I'm archiving to publish ios from my Xamarin forms project, but I get an error ;

I've put my project on a shorter path to fix this error. (In :C). But , I keep getting errors. Because I think archive files are being created in a very different place. I couldn't solve this problem. How do I move the archive files? Ultimately these files in AppData. Wouldn't it be a mistake to relocate them?

My project location

My project archive location

What should I do. Please help me !

Binding problems

$
0
0


Hello comunity

I am using a collectionView

  <ContentPage Title="Master"
                     Padding="15">
            <StackLayout Orientation="Vertical">
                <StackLayout Orientation="Vertical">
                    <StackLayout Orientation="Horizontal"
                                 HorizontalOptions="FillAndExpand">
                        <Image Source="xamagon.png"
                               BackgroundColor="Transparent"
                               HeightRequest="100"
                               WidthRequest="100"
                               VerticalOptions="Center" />

                        <StackLayout Orientation="Vertical">
                            <Label Text="Xamarin"
                                   HorizontalTextAlignment="Start"
                                   FontSize="Large"
                                   Margin="2,0,0,0"
                                   HorizontalOptions="Start"
                                   VerticalOptions="EndAndExpand"
                                   TextColor="Black" />
                            <Label Text="Xamarin Forms"
                                   HorizontalTextAlignment="Start"
                                   FontSize="Small"
                                   Margin="2,0,0,0"
                                   HorizontalOptions="Start"
                                   VerticalOptions="StartAndExpand"
                                   TextColor="#16161d" />
                        </StackLayout>
                    </StackLayout>

                    <StackLayout BackgroundColor="Black"
                                 MinimumHeightRequest="1"
                                 Orientation="Vertical"
                                 HeightRequest="1"
                                 HorizontalOptions="FillAndExpand">
                        <Label Text="fff"
                               FontSize="1"
                               TextColor="Black"
                               BackgroundColor="Black"
                               HorizontalOptions="CenterAndExpand" />
                    </StackLayout>
                    <CollectionView x:Name="menuList"
                                    SelectionMode="Single"
                ItemsSource="{Binding HamburgersItems}">
                        <CollectionView.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="10">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="auto" />
                                    </Grid.ColumnDefinitions>
                                    <StackLayout Orientation="Horizontal"
                                                 HorizontalOptions="Center"
                                                 VerticalOptions="Center">
                                        <Image Source="{Binding HamburgersItems.ImgSource }"
                                               Aspect="AspectFit"
                                               WidthRequest="37"
                                               HeightRequest="37" />
                                        <Label Text="{Binding HamburgersItems.Title}"
                                               VerticalOptions="Center"
                                               HorizontalOptions="Center"
                                               Grid.Column="1" />
                                    </StackLayout>
                                </Grid>
                            </DataTemplate>
                        </CollectionView.ItemTemplate>
                    </CollectionView>
                </StackLayout>
            </StackLayout>
        </ContentPage>
    </MasterDetailPage.Master>
    <MasterDetailPage.Detail>
        <NavigationPage BarBackgroundColor="{StaticResource PrimaryColor}">
            <x:Arguments>
                <ContentPage Padding="10">
                    <NavigationPage.TitleView>
                        <StackLayout Spacing="30"
                                     Orientation="Horizontal"
                                     VerticalOptions="Center"
                                     HorizontalOptions="Center">
                            <Image Source="LogoTexto.png"
                                   Margin="0,0,50,0"
                                   WidthRequest="200" />
                            <Image Source="CampanaNotificaciones.png">
                            </Image>
                        </StackLayout>
                    </NavigationPage.TitleView>
                    <ContentPage.Content>
                        <ScrollView>
                            <StackLayout>
                                <StackLayout Margin="10,20,0,0"
                                             Orientation="Horizontal">
                                    <Image Source="Perfil"
                                           WidthRequest="30"
                                           HeightRequest="30" />
                                    <Label Text="Toca aqui para agregar una foto"
                                           VerticalOptions="Center" />
                                </StackLayout>
                                <StackLayout Margin="10,30,10,0"
                                             Spacing="20">
                                    <Label Text="Nombre del usuario" />
                                    <Label Text="Datos Personales"
                                           Style="{StaticResource SeparatorTextStyle}" />
                                    <Entry Placeholder="Nombre" />
                                    <Entry Placeholder="Segundo Nombre" />
                                    <Entry Placeholder="Apellido" />
                                    <Entry Placeholder="Segundo apellido" />
                                    <renders:ExtendedDatePicker />
                                    <Picker Title="Genero" />
                                    <Label Text="Ubicación"
                                           Style="{StaticResource SeparatorTextStyle}" />
                                    <Picker Title="Nacionalidad" />
                                    <Entry Placeholder="Documento de identidad" />
                                    <Picker Title="Pais" />
                                    <Picker Title="Estado" />
                                    <Picker Title="Ciudad" />
                                    <Picker Title="Municipio" />
                                    <Entry Placeholder="Dirección" />
                                    <Label Text="Información de contacto"
                                           Style="{StaticResource SeparatorTextStyle}" />
                                    <Entry Placeholder="Teléfono local" />
                                    <Entry Placeholder="Teléfono Celular" />
                                    <Entry Placeholder="Correo eletrónico" />
                                    <Entry Placeholder="Correo eletrónico secundario" />
                                    <Label Text="Acerca de mi"
                                           Style="{StaticResource SeparatorTextStyle}" />
                                    <Editor Placeholder="Una breve descripción"
                                            AutoSize="TextChanges" />
                                    <Button Text="Guardar"
                                            Margin="0,0,0,20"
                                            Style="{StaticResource YellowButtons}"
                                            HorizontalOptions="Center" />
                                </StackLayout>
                            </StackLayout>
                        </ScrollView>

                    </ContentPage.Content>
                </ContentPage>
            </x:Arguments>
        </NavigationPage>
    </MasterDetailPage.Detail>

this is my code behind

 public ProfileScreen() {
            InitializeComponent();

            DependencyService.Get<IStatusBar>().HideStatusBar();

            BindingContext = new ProfileViewModel();
        }
    }

And I have this is view model, that declare a list of hamburger icons, that has 9 items on it, and for some reason it doesn't show anything

  class ProfileViewModel : BaseViewModel {
        private string result;
        public ICommand GoToHome { get; set; }

        public List<Hamburger> HamburgersItems { get; set; }

        public ProfileViewModel() {

            HamburgersItems = new List<Hamburger>();

            HamburgersItems = HamburgerService.GetHamburgerItems();

            GoToHome = new Command(async () => {

                var oauthToken = await SecureStorage.GetAsync("oauth_token");

                Debug.WriteLine($"token {oauthToken}");

                var obj = await NetworkHelpper.ReciveData(Constants.PROFILE_USER, oauthToken);

                if (obj.IsSuccessStatusCode) {
                    Debug.WriteLine(result = obj.Content.ReadAsStringAsync().Result);
                }

                //await Application.Current.MainPage.Navigation.PushAsync(new HomeScreen());
            });
        }
    }
   const string MENSAJES = "Mensajes";
            const string SERVICIOS_AGENDADOS = "Servicios Agendados";
            const string CONTROL_DE_TU_MASCOTA = "Control de tu mascota";
            const string MAPA_PET_FRIENDLY = "Mapa pet friendly";
            const string LEARNING_CENTER = "Leaning Center";
            const string NOTICIAS = "Noticias";
            const string SOPORTE = "Asistencia Tecnica";
            const string COMPARTIR_APP = "Compartir app";
            const string LOG_OUT = "Log out";


            return new List<Hamburger>() {

                new Hamburger(){ Title = MENSAJES,
                    ImgSource = "Mensajes.png", },
                new Hamburger(){ Title = SERVICIOS_AGENDADOS,
                    ImgSource = "ServiciosAgendados.png", },
                new Hamburger(){ Title = CONTROL_DE_TU_MASCOTA,
                    ImgSource = "ControlMascota.png", },
                new Hamburger(){ Title = MAPA_PET_FRIENDLY,
                    ImgSource = "MapaPetFriendly.png"},
                new Hamburger(){ Title = LEARNING_CENTER,
                    ImgSource = "LearningCenter.png", },
                new Hamburger(){ Title = NOTICIAS,
                    ImgSource = "",},
                new Hamburger(){ Title = SOPORTE,
                    ImgSource = "Soporte.png"},
                new Hamburger(){ Title = COMPARTIR_APP,
                    ImgSource = "Compartir.png"},
                new Hamburger(){ Title = LOG_OUT,
                    ImgSource = ""}
            };
        }

MVVM - What is the essential requirement for an application to be regarded as such

$
0
0

When I began looking at Xamarin Forms for the first time, one very basic tutorial specifically provided a case for MVVM - see image below. I know there is a division into Model, ViewModel and Views, which this example follows clearly. Occasionally it seems unclear whether other approaches are technically MVVM, for example when their structure isn't organised exactly in this form. In this case the principle logic is contained within MainPageViewModel.cs, with almost no code at all in MainPage.xaml.cs.

By contrast, could the following project within the Xamarin documentation be regarded as MVVM? It consists of a specific class for database operations (Data sub-folder) and another for defining the data (Models sub-folder), together with a main page which provides the necessary list functionality. It is split in a similar way, but is it MVVM?

badge number in toolbar items on Shell template

Hide time in status bar for Android and iOS

$
0
0

Hi, I would like to hide the time in the status bar for Android and iOS (but not for UWP), so I would like
to do it in the Platfrom Project, and not in the Xmarin.Forms project.

In iOS:
I understood I need to do it via info.plist.
1. In Application tab (Checking the Hide status bar check box).
2. In Source tab (Add a property of "Status bar is initially hidden" and setting it to "Yes").

The problem is that there is no such a tab "Source" (At least not in Visual Studio 2019).

In Android:
What is the equivalent file in Andorid for info.plist?

Thank you,
Eliran.

Best package for handling text from pdf?

$
0
0

What is the best package for reading (and maybe displaying) text from pdf documents. The text displayed must be selectable but not editable.

There are quite a number of NuGet packages for pdf. Which is the best for my purpose?

— Eigil


Self-contained deployment of gtk app to linux ?

$
0
0

How do I create a Self-contained deployment GTK app. for linux ?

Best regards
Eigil

Xamarin Forms MSAL Hangs

$
0
0

In my Xamarin Forms app using MSAL, the UWP project runs and authenticates as expected. However, the Android project "hangs" after the sign-in is partially completed. "Sign In", "Are You Trying " screen, then hangup, …. With the UWP project, "Sign In" and then project continues.

If I created an app with a Blank Template and just a single Main Page, my code works correctly, the user is Authenticated and program completes as expected. However, if I change the program to a Tabbed Template with multiple pages, the program "hangs" during Authentication.

I have added the code to the Android MainActivity.cs file.

I've tried to change the line with the following because this is where I'm stuck.

> global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
App.ParentWindow = this

Here is my MainActivity.cs

` [Activity(Label = "MyEMR", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{

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

        global::Xamarin.Forms.Forms.Init(this, bundle);
        LoadApplication(new App());
        App.ParentWindow = this;
    }

    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
    {
        Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

        base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    }

    protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
    {
        base.OnActivityResult(requestCode, resultCode, data);
        AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
    }

}

`

Crashlog

$
0
0

Hello Everyone!

I am getting a crash on iOS and am having trouble finding out the source of the crash. Since I am not that used to reading crashlogs I thought I would ask here :)

The crash occurs only on iOS and happens the second time that you put the app to sleep.

Can anyone make help me to make sense of the crashlog?

Can't Open WhatsApp in xamarin ios

$
0
0

how can I open WhatsApp from my app to a specific number? For Android, the following is working fine

But it didn't work in IOS. What's App Open and then Show Message (This Link couldn't be opened Check the link and try again)

Here is my code for shared Project:

try
{

if (await Launcher.TryOpenAsync(new Uri("whatsapp://send?phone=+" + mobile)))
await Launcher.OpenAsync(new Uri("whatsapp://send?phone=+"+ mobile));
else
await Rg.Plugins.Popup.Services.PopupNavigation.PushAsync(new ShowMessagePage("Install Whatsapp", 5000));

}
catch (Exception ex)
{
await Rg.Plugins.Popup.Services.PopupNavigation.PushAsync(newShowMessagePage(Helpers.TranslateExtension.Translate("Error"), 5000));

}

I Added That in info.plist

LSApplicationQueriesSchemes

whatsapp

Xamarin.Essentials Web Authenticator

$
0
0

Why i get exception "You must subclass the WebAuthenticatorCallbackActivity and create an IntentFilter for it which matches your callbackUrl." when set urn:ietf:wg:oauth:2.0:oob in DataScheme?

My redirectUrl = "urn:ietf:wg:oauth:2.0:oob://" and i try set just "urn:ietf:wg:oauth:2.0:oob" and again get this exception.

Viewing all 79144 articles
Browse latest View live


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