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

TapGestureRecognizer - using NumberOfTapsRequired for double tap

$
0
0

Ideally I'm looking for a LongTap event or GestureRecognizer but as yet that doesn't exist in .Forms (hopefully next release!) so as a temporary workaround to my situation where my app normally uses tap to open and longtap (tap and hold) to show a popup context menu I thought I'd use tap to open and double tap to show the context menu as TapGestureRecognizer has a property NumberOfTapsRequired which should do the trick .. however I'm having problems working out how to do this.

Based on the following code, whilst the second doubletapped function is indeed only called when a double tap occurs, the first tapped function is called both for a tap and a double tap but without any way as far as I can tell to know in the tapped function that this is a double tap and hence to ignore it.

    public someObject() : base()
    {
        var tgr = new TapGestureRecognizer();
        tgr.NumberOfTapsRequired = 1;
        tgr.Tapped += tapped;
        GestureRecognizers.Add(tgr);

        var ttgr = new TapGestureRecognizer();
        ttgr.NumberOfTapsRequired = 2;
        ttgr.Tapped += doubletapped;
        GestureRecognizers.Add(ttgr);
    }
    private void tapped(object sender, EventArgs e)
    {
    // deal with tap
    }
    private void doubletapped(object sender, EventArgs e)
    {
        // deal with doubletap
    }

I would've hoped that perhaps in the EventArgs of tapped it would have the number of taps so I could then ignore double taps within it or is there some other way to deal with it?

Thanks


How read metadata with crossmediamanager in audio stream

$
0
0

public async void PlayStream()
{
var mediaItem = await CrossMediaManager.Current.Play("URL");
mediaItem.MetadataUpdated += (sender, args) => {
title = args.MediaItem.Title;
};
}
Everything works correctly with an mp3 file, while metadata is not received with a streaming stream. Why ?

Xamarin.Forms SOAP output style

$
0
0

Hi,
i call a soap 1.1 web service from my xamarin forms app (.netstandard 2.0). I generated the reference.cs file in my .android project. Then when i watch the request with fiddler, i see, there is a outcomming xml like this:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Header />
    <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <q1:testMaterial xmlns:q1="example.com/testWS"><testMaterialRequest href="#id1" />
         </q1:testMaterial>
         <q2:testMaterialRequestType id="id1" xsi:type="q2:testMaterialRequestType" xmlns:q2="example.com/testWS">
            <DataArea href="#id2" />
         </q2:testMaterialRequestType>
         <q3:Array id="id2" xmlns:q4="example.com/testWS" q3:arrayType="q4:testMaterialRequestTypeTestWS[1]" 
          xmlns:q3="http://schemas.xmlsoap.org/soap/encoding/">
             <Item href="#id3" />
         </q3:Array>
         <q5:testMaterialRequestTypeTestWS id="id3" xsi:type="q5:testMaterialRequestTypeTestWS" xmlns:q5="example.com/testWS">
           <ItemBarcode xsi:type="xsd:string">0036400780070001</ItemBarcode>
           <MachineBarcode xsi:type="xsd:string">2342423</MachineBarcode>
         </q5:testMaterialRequestTypeTestWS>
    </soap:Body>
</soap:Envelope>

When i call the same web service from a windows forms project (.net framework 4.7) i got a request xml like this:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <testMaterial xmlns="example.com/testWS">
        <reportthrombexinRequest xmlns="">
          <DataArea><testWS>
            <ItemBarcode>0036400780070001</ItemBarcode>
            <MachineBarcode>2342423</MachineBarcode>
          </testWS>
          </DataArea>
        </testMaterialRequest>
        </testMaterial>
      </soap:Body>
</soap:Envelope>

I see, xamarin (respectively mono) generate a soap 1.1 message with using multible references like href... and id... .
Is there a way xamarin to say that it will generate a request without using "multible references" like .netFramework?

Xamarin.Forms MicroCharts BarChart with Multiple Values

$
0
0

I'm using MicroCharts barChart:
I import everything.

I read a list of data from Api. I need to show the data grouped by parameter year(i read from every object from the list) and have 3 values for every year to show. Similar like this example:

Any suggestions?

Calendar Events not working properly in MS Graph API ???

$
0
0

Hi,

I am working on Outlook Calendar Events integration using Microsoft Graph Api in Xamarin forms. Also, i have done with the Authentication part
but i have some queries related to fetching of Calendar Events.

Q. I am able to fetch Calendar Events through my code , but its limited to "10" events only. I am not able to fetch all my outlook calendar events.

   Client = new GraphServiceClient("https://graph.microsoft.com/v1.0/",
                      new DelegateAuthenticationProvider(async (requestMessage) =>
                      {        
                          requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", authResult.AccessToken);                         
                      }));
                var events = await Client.Me.Calendar.Events.Request().GetAsync();                            
                var appointmentList = events.ToList();
                foreach (var appointment in appointmentList)
                {
                    Random randomTime = new Random();
                    Meetings.Add(new Model.Meeting()
                    {
                        From = Convert.ToDateTime(appointment.Start.DateTime).ToLocalTime(),
                        To = Convert.ToDateTime(appointment.End.DateTime).ToLocalTime(),
                        EventName = appointment.Subject,
                        Color = colorCollection[randomTime.Next(9)]
                    });
                }``

Can anyone help me out to fetch all the calendar events??

Thanks.

iOS Simulator in Windows or Linux?

$
0
0

Is there any source from where i can get iOS simulator for testing of my app? Thanks in advance.

ListView ItemsSource Binding in XAML Problem

$
0
0

when i change SelectedIndexChanged from picker i get data from Api to fill ListView but not Wotking
i try with & without fody.
SelectedIndexChanged is a behavoir picker

I use :
xamarin froms : 4.4.0.991537 v
PropertyChanged.Fody : 2.5.13 v

Listview Code :

                  <ListView  x:Name="RolesList" Margin="0,10,0,0"   ItemsSource="{Binding RolesUsers}">
                          <ListView.ItemTemplate>
                               <DataTemplate>
                                  <ViewCell>
                                        <StackLayout Orientation="Horizontal">
                                          <CheckBox HorizontalOptions="Start" IsChecked="{Binding IsSelected}" />
                                         <Label  HorizontalOptions="Start" Text="{Binding Name}" TextColor="Red" FontSize="13" />
                                         </StackLayout>
                                </ViewCell>
                              </DataTemplate>
                            </ListView.ItemTemplate>
                            <ListView.Footer>
                                 <StackLayout Padding="5,5,5,5">
                                      <Button
                                       BackgroundColor="Green"
                                          BorderRadius="5"
                                    Command="{Binding AddCommand}"
                                         CommandParameter="{Binding RolesUsers}"
                                       Text="Sauvegarder"
                                         TextColor="White"
                                        VerticalOptions="Center" />
                                </StackLayout>
                           </ListView.Footer>
                       </ListView>

ViewModel:

 public class ManagerRolesViewModel : BaseViewModel
    {

        public List<UserInfo> UserInfos { get; set; }

        public UserInfo SelectedUser { get; set; }
        public bool ListRolesVisibility { get; set; }
        public ObservableCollection<RoleForCheckBox> rolesUsers;


        public ObservableCollection<RoleForCheckBox> RolesUsers
        {
            get => rolesUsers;
            set => SetProperty(ref rolesUsers, value);
        }

        public ManagerRolesViewModel()
        {
           // this.TestCommand.Execute(null);

        }
        public ManagerRolesViewModel(string userId)
        {
            this.GetRolesByUserCommand.Execute(userId);
        }
        public override async void OnAppearing()
        {
            base.OnAppearing();

            this.GetUsersAndRolesCommand.Execute(null);
        }


        public ICommand GetRolesByUserCommand
        {
            get
            {
                return new Command<string>(async (userId) =>
                {
                    var result = await Api.GetListRolesByUsers(userId);
                    RolesUsers = result.data;
                    ListRolesVisibility = true;
                });
            }
        }
    }
}

PickerViewBehavior :

public class PickerViewBehavior : Behavior<Picker>
    {

        protected override void OnAttachedTo(Picker bindable)
        {
            bindable.SelectedIndexChanged += Bindable_SelectedIndexChanged;
        }

        protected override void OnDetachingFrom(Picker bindable)
        {
            bindable.SelectedIndexChanged -= Bindable_SelectedIndexChanged;
        }

        void Bindable_SelectedIndexChanged(object sender, EventArgs e)
        {
            UserInfo selectedUser = ((Picker)sender).SelectedItem as UserInfo;
            if (selectedUser == null)
            {
                ((Picker)sender).SelectedItem = null;
                return;
            }
            var vm = new ManagerRolesViewModel();
            vm.GetRolesByUserCommand.Execute(selectedUser.UserId);

        }
    }

AudioTrack couses short stops?

$
0
0

I have an app streaming music to another phone via Bluetooth. The app decodes mp3 to pcm data and then sends it. The problem is the sound stutters sometimes, but plays ok other times. The play method looks like this:

    public void Read()
    {
        System.Threading.Tasks.Task.Run(() =>
        {
            int _bufferSize;
            AudioTrack _output;

            _output = new AudioTrack(Android.Media.Stream.Music, 44100, ChannelOut.Stereo, Android.Media.Encoding.Pcm16bit,
                10000, AudioTrackMode.Stream);
            _output.Play();

            byte[] myReadBuffer = new byte[1000];
            //byte[] check = new byte[1];

            System.Threading.Tasks.Task.Run(() =>
            {
                while (true)
                {
                    try
                    {
                        mmInStream.Read(myReadBuffer, 0, myReadBuffer.Length);
                        _output.Write(myReadBuffer, 0, myReadBuffer.Length);
                        //mmOutStream.Write(check);
                    }
                    catch (System.IO.IOException ex)
                    {
                        System.Diagnostics.Debug.WriteLine("Input stream was disconnected", ex);
                    }
                }
            }).ConfigureAwait(false);
        }).ConfigureAwait(false);
    }

And after a while it stops and displays this:

    02-03 19:08:58.019 W/AudioTrack( 3986): releaseBuffer() track 0xc5e2de00 disabled due to previous underrun, restarting

How would I fix this?


XF-Material

$
0
0

hi
Is it supported? XF-Material in uwp?

FlyoutHeader doesnot display a ContentView page

$
0
0

i am new to xamarin forms, i'm learning about Shell. i try to display a content view inside a shell flyout header but it doesnot display.
This is the shell page

<?xml version="1.0" encoding="utf-8" ?>
<Shell
    x:Class="XamarinShell.AppShell"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:controls="clr-namespace:XamarinShell.Controls"
    xmlns:d="http://xamarin.com/schemas/2014/forms/design"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:views="clr-namespace:XamarinShell.Views"
    HeightRequest="200"
    mc:Ignorable="d">
    <Shell.FlyoutHeader>
        <controls:FlyoutHeader/>
    </Shell.FlyoutHeader>
    <FlyoutItem Title="Phone Call" Icon="icons_phone.png">
        <ShellContent ContentTemplate="{DataTemplate views:PhoneCallPage}" />
    </FlyoutItem>
    <FlyoutItem Title="Settings" Icon="icons_settings.png">
        <ShellContent ContentTemplate="{DataTemplate views:SettingsPage}" />
    </FlyoutItem>
</Shell>

This is the header view

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="XamarinShell.Controls.FlyoutHeader"
    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"
    mc:Ignorable="d">
    <ContentPage.Content>
        <Grid BackgroundColor="Black" HeightRequest="200">
            <Image
                Aspect="AspectFill"
                Opacity="0.6"
                Source="xamarinstore.jpg" />
            <Label
                FontAttributes="Bold"
                HorizontalTextAlignment="Center"
                Text="Animals"
                TextColor="White"
                VerticalTextAlignment="Center" />
        </Grid>
    </ContentPage.Content>
</ContentPage>

Problem with my First XF Nuget Package

$
0
0

Hi,

I am trying to create a Nuget package to be used for my Xamarin Forms apps.

I am just starting a simple package to DisplayAlert like this:

private void Button_Clicked(object sender, EventArgs e)
{
    OneID.Signin.Log("Hello");
}

but I am getting:

System.NullReferenceException: 'Object reference not set to an instance of an object.'

My Nuget is created as a .NET Stranded Library Class, then I added a Signin Class file like this:

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

namespace OneID
{
    public class Signin
    {
        private static Page page;

        public static void Log(string text)
        {
            page.DisplayAlert("Test", "Ok", "Yes");
        }
    }
}

so Why I am getting the NullReferenceException error?

Thanks,
Jassim

iOS 13.0 Broke MasterDetailPage on iPads?

$
0
0

I have noticed that after updating iOS to v13.0, the MasterDetailPage is broken on iPads but it's still working on iPhones and Androids.
By broken I mean the whole page is white, without content.


The only way to fix this is to update Xamarin.Forms to the latest v4.2+.

The problem is that some other packages are not compatible (XF broke something else after v4.0) so I cannot update XF yet.
The App Store is rejecting my app because it shows a white screen on iPads with iOS 13.0+....so I would have to stop targeting iPads!

Try for yourself, here is a basic sample repo with MasterDetail page (the default Xamarin Forms template with MasterDetailPage).
https://github.com/stesvis/MasterDetailTest2

The same happens with Prism MasterDetailsPage:
https://github.com/stesvis/MasterDetailTest

  • iPhones: works
  • iPad -> iOS 12.2: works
  • iPad -> iOS 13.0: white screen

Any solution for this HUGE headache?

How hide tooltip map of xamarin forms?

$
0
0

Hello, How hide tooltip map of Xamarin forms on Android and iOS, or how not show tooltip when does tap on Pin?

I need to open my app on clicking a specific url?

$
0
0

If my xamarin.forms app is installed in phone then clicking on a specific url(with id) should open a page, if not it should redirected to the app store to install my app.

Unable to download Image from URL Xamarin Form

$
0
0

I am developing a Xamarin app which retrives info from DB, take/choose photo and upload them to remote server, display this images from the remote server and the user can delete them by tap on and press a button. The final step is to download the images stored in the server to the local device gallery.

This is my current button click event:

private void button_download_image_Clicked(object sender, EventArgs e)
{
        Uri image_url_format = new Uri(image_url);
        WebClient webClient = new WebClient();
        try
        {              
            webClient.DownloadDataAsync(image_url_format);
            webClient.DownloadDataCompleted += webClient_DownloadDataCompleted;
        }
        catch (Exception ex)
        {
            DisplayAlert("Error", ex.ToString(), "OK");
        }
}

Below the webClient_DownloadDataCompleted method:

private void webClient_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
    try
    {
        Uri image_url_format = new Uri(image_url);
        byte[] bytes_image = e.Result;
        Stream image_stream = new MemoryStream(bytes_image);
        string dest_folder= Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).ToString();
        string file_name= Path.GetFileName(image_url_format.LocalPath);
        string dest_path= Path.Combine(dest_folder, file_name);
        using (var fileStream = new FileStream(dest_path, FileMode.Create, FileAccess.Write))
        {
              image_stream.CopyTo(fileStream);
        }
              DisplayAlert("Alert", "Download completed!", "OK");
        }
        catch (Exception ex)
        {
            DisplayAlert("Error", ex.ToString(), "OK");
        }
    }

But it does not work, no error caught, I get the alert which warn me that the download is completed. Also I gave permission for internet, write_external_storage and read_external_storage.

Another thing is that the images after some time, appears in the gallery under Download album which is correct.

Any idea about this behavior?


Xamarin Custom Renderer: overridden method not called

$
0
0

Context (in case you are not familiar with screen-readers). Screen-readers are available on iOS (VoiceOver) and Android (TalkBack) to support accessibility to people with sever visual impairments. In a nutshell, when the screen-reader is activated and the user touches a UI elements, it gets the “accessibility focus" (the “on tap” event is not fired) and then, when the user double taps, the “on tap” event is fired. In native iOS and Android code it is possible to override methods to specify what to do when a UI element gets or loses the accessibility focus. The methods are called onPopulateAccessibilityEvent (for Android in Java) and accessibilityElementDidBecomeFocused() (for iOS in Swift). Almost the same for C# in Xamarin View.OnPopulateAccessibilityEvent for Android and UIResponder.AccessibilityElementDidBecomeFocused Method for iOS).

Problem 1. I couldn’t find a method in Xamarin Forms to manage the accessibility focus events (when the UI element gets or loses the accessibility focus). Do you know if such methods exist in Xamarin Forms? In case they don’t, we believe that they are very important for the development of accessibile applications, so we would like to suggest to add them. Do you know which is the procedure to suggest the Xamarin team to implement a new functionality?

Problem 2. In order to overcome Problem 1, I am trying to make a Custom Renderer that uses native buttons. The custom rendered seems to be correctly initialized (the right message is logged) and shown on the screen. However, the overridden methods are not called. Code is shown below and available Git Repository. Am I doing something wrong?

MainPage.Xaml.cs (in Forms, CustomViewAccessibility):

using System;
using System.ComponentModel;
using Xamarin.Forms;

namespace CustomViewAccessibility
{
    [DesignTimeVisible(false)]
    public partial class MainPage : ContentPage
    {

        public MainPage()
        {
            InitializeComponent();

            ICustomViewRenderer mybutton = new ICustomViewRenderer();
            AutomationProperties.SetIsInAccessibleTree(mybutton, true);
            stacklayout.Children.Add(mybutton);                
        }
    }
}

ICustomViewRenderer.cs (in Forms, CustomViewAccessibility):
`using System;
using Xamarin.Forms;

namespace CustomViewAccessibility
{
    public class ICustomViewRenderer: Button
    {
        public ICustomViewRenderer()
        {
        }
    }
}`

AndroidCustomView.cs (in Android, CustomViewAccessibility.Android):

`using System;
using Android.Content;
using Android.Views.Accessibility;
using CustomViewAccessibility;
using CustomViewAccessibility.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(ICustomViewRenderer), typeof(AndroidCustomView))]
namespace CustomViewAccessibility.Droid
{
    public class AndroidCustomView: ButtonRenderer
    {
        public AndroidCustomView(Context context) : base(context)
        {
        }

        protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
        {
            base.OnElementChanged(e);

            if(Control == null)
            {
                return;
            }

            Console.WriteLine("PIPPO created from Android");
            Control.SetBackgroundColor(Android.Graphics.Color.Orange);
        }

        public override void OnPopulateAccessibilityEvent(AccessibilityEvent e)
        {
            base.OnPopulateAccessibilityEvent(e);

            if (e.EventType == EventTypes.ViewAccessibilityFocused)
            {
                Console.WriteLine("PIPPO I am in focus");
            }
        }
    }
}`

IOSCustomView.cs (in iOS, CustomViewAccessibility.iOS):

`using System;
using CustomViewAccessibility;
using CustomViewAccessibility.iOS;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(ICustomViewRenderer), typeof(IOSCustomView))]
namespace CustomViewAccessibility.iOS
{
    public class IOSCustomView: ButtonRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
        {
            base.OnElementChanged(e);

            if(Control == null)
            {
                return;
            }

            Console.WriteLine("PIPPO created from IOS");
            Control.BackgroundColor = UIColor.Red;
        }

        public override void AccessibilityElementDidBecomeFocused()
        {
            base.AccessibilityElementDidBecomeFocused();
            Console.WriteLine("PIPPO I am in focus");
        }
    }
}`

Javascript funcionality in C# and xamarin

$
0
0

Example of code in javascript:

function OnChangeEvent(){

if (_btnChange !== null) {
                window.clearTimeout(_btnChange ); //cancel the previous timer.
                _btnChange = null;
}
 _btnChange = window.setTimeout(function () { commitChanges(item); }, 3000);

}

function commitChanges(item){
window.clearTimeout(_btnChange );
_btnChange = null;

//Actual code that needs to execute is here

}

Explanation what this code does:
I have 3 (or more, doesnt matter) buttons and on click event is called OnChangeEvent function. This code ensure that when i click on one button it starts timer of 3 seconds and if inside that period of 3 seconds user clicks on different button that time resets and so on. With this i make sure the last clicked button gets executed.

And this control is much more like selection group buttons then real buttons.
How to do this in C# and xaml. I tried using system.Timers.Timer and tried with cancellation task but did not make it work. There should be something simpler.

Xamarin Forms Firebase Cloud Messaging

$
0
0

i've configuring my xamarin form apps for 1 week and still no luck. im using latest xamarin form. the issue is OnNewToken method is not called.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.Graphics;
using Android.Media;
using Android.OS;
using Android.Runtime;
using Android.Support.V4.App;
using Android.Util;
using Android.Views;
using Android.Widget;
using Firebase.Messaging;

namespace XamarinFirebaseExample.Droid
{
    [Service(Name = "mypackage.MyFirebaseMessagingService")]
    [IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
    public class MyFirebaseMessagingService : FirebaseMessagingService
    {
        private const string defaultNotificationTitle = "App name";
        private const string newsChannelId = "1"; // not sure I just use 1 you should be able to use anything as long as its unique per channel
        private const string newsChannelDescription = "Channel name shown to user e.g. News";
        private long[] vibrationPattern = { 500, 500, 500, 500, 500, 500, 500, 500, 500 };
        private NotificationManager notificationManager;

        public override void OnNewToken(string newToken)
        {
            base.OnNewToken(newToken);
            Log.Info("MyFirebaseMessagingService", "Firebase Token: " + newToken);
            saveRegistrationToApp(newToken);
        }

        public override void OnMessageReceived(RemoteMessage remoteMessage)
        {
            base.OnMessageReceived(remoteMessage);
            // depending on how you send the notifications you might get the message as per documentation
            // using remoteMessage.getNotification().getBody()
            var message = remoteMessage.Data["message"];
            Log.Debug("MyFirebaseMessagingService", "From:    " + remoteMessage.From);
            Log.Debug("MyFirebaseMessagingService", "Message: " + message);

            sendNotification(defaultNotificationTitle, message);
        }

        private void sendNotification(string title, string message)
        {
            var intent = new Intent(this, typeof(MainActivity));
            intent.AddFlags(ActivityFlags.SingleTop);
            var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);
            notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);

            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
            {
                NotificationImportance importance = NotificationImportance.High;
                NotificationChannel notificationChannel = new NotificationChannel(newsChannelId, newsChannelDescription, importance);
                notificationChannel.EnableLights(true);
                notificationChannel.LightColor = Color.Red;
                notificationChannel.EnableVibration(true);
                notificationChannel.SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification), new AudioAttributes.Builder()
            .SetContentType(AudioContentType.Sonification)
            .SetUsage(AudioUsageKind.Notification)
            .Build());
                notificationManager.CreateNotificationChannel(notificationChannel);
            }

            Notification notification = new NotificationCompat.Builder(this, newsChannelId)
                .SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Mipmap.icon)) //newest projects use mipmaps and drawables, you can go to drawables too
                .SetSmallIcon(Resource.Mipmap.icon)
                .SetContentTitle(title)
                .SetContentText(message)
                .SetAutoCancel(true)
                .SetVisibility((int)NotificationVisibility.Private)
                .SetContentIntent(pendingIntent)
                .SetVibrate(vibrationPattern)
                .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
                .Build();

            notificationManager.Notify(0, notification); // overrides old notification if it's still visible because it uses same Id
        }

        private void saveRegistrationToApp(string token)
        {
           // send to server or store locally
        }
    }
}

Xamarin Forms Database backup sqlite

$
0
0

This is my code to take sqlite backup. There are no errors but can't find any database file in my location.

Please help.

How to change Label TextColor with binding property of ViewModel in MVVM?

$
0
0

<Label Text="EmpName" TextColor="{Binding emp_color}" />
I have created Label control with TextColor bindable property which is declared in ViewModel in separate project from Xamarin.Forms and Native. I need to change this Label TextColor dynamically.

Viewing all 77050 articles
Browse latest View live


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