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

Video can not start after clicking the play button after stop button.

$
0
0

Help me.......
This is My Code..................................
button = FindViewById(Resource.Id.btnplay);
button.Click += Button_Click;

        button1 = FindViewById<Button>(Resource.Id.btnstop);
        button1.Click += Button1_Click;
    }

    private void Button1_Click(object sender, System.EventArgs e)
    {
        var videoView = FindViewById<VideoView>(Resource.Id.SampleVideoView);
        videoView.StopPlayback();
    }

    private void Button_Click(object sender, System.EventArgs e)
    {
        var videoView = FindViewById<VideoView>(Resource.Id.SampleVideoView);
        videoView.Start();


    }

Can't archive my android project, "this package may not be fully compatible"

$
0
0

Whenever I try to archive my android project into an APK, I get this warning which prevents me from archiving:

Package 'Plugin.MediaManager 0.4.51' was restored using '.NETFramework version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.01. This package may not be fully compatible with your project.

The project builds just fine. Any ideas? The plugin I'm using 'Plugin.MediaManager' is essential and I need it in my project.

Thanks

Navigate to viewcontroller from AppDelegate

$
0
0

When my app is running in the background and the app receive a notificaionthe the user can click on the notification. Doing this calls DidReceiveRemoteNotification(...) in AppDelegate.

In DidReceiveRemoteNotification I would like to take the user to a specific viewcontroller. I have tryed several ways but not found something that works.

Method1
UIStoryboard board = UIStoryboard.FromName("Main", null);
SpecificCtrl ctrl = (SpecificCtrl)board.InstantiateViewController("SpecificCtrl");
UINavigationController nav = new UINavigationController(ctrl);
Window.RootViewController.PresentViewController(nav, true, null);

Result: The viewcontroller is loaded but the navigationbar and toolbar are empty. Also there is no way to go back.

Method2
UIStoryboard board = UIStoryboard.FromName("Main", null);
SpecificCtrl ctrl = (SpecificCtrl)board.InstantiateViewController("SpecificCtrl");
Window.RootViewController.PresentViewController(ctrl , true, null);<del

Result: The viewcontroller is loaded but the navigationbar and toolbar are not present

Question
Do you have any suggestions? The storyboard is found, the specificctrl have storyboard id specified and the navigation actually work. But somehow the navigationbar and toolbar are not loaded properly

How to set the Selected Item of a Picker Control through View Model (MVVM)

$
0
0

Hi there,

I will try to explain this as best I can so please bare with me:

Background:

I have two pages that interact with each other - a customer page (CustomerPage) which stores a listing of customers and an edit page (CustomerEditPage) used to add new customers or edit customers passed in from the customer page list. I am able to pass the Customer class of the selected customer in the customer page to the edit customer page without issue. I am also able to set all of the Entry controls to the values through passing the values. In addition to the Entry controls I also have a Picker control used to store location name values (e.g. 123 West St, 85 George St, etc.). It has an ItemSource that loads successfully through the view model. However I have an issue when trying to specify the selected item from a value passed to the view model on load. The bound property fires and shows it being set, but the control does not show anything selected after load in the application. If I click on the control, my values are there but again nothing is selected.

Can someone help me explain how I can set the selected item?

Things I have tried:

  • Ensuring the ItemSource is loaded before the SelectedItem value is set
  • Put a break-point on the Handles_ItemSelected event to see when it is firing (*Note it only fires when I select an item from the list and NOT when set through code in the view model)
  • Adding an ID column to the CustomerLocation class to see if the Picker needed a key value

Item Selected from ListView in CustomerViewModel.cs

        ItemSelectedCommand = new Command(async () =>
        {
            await navigationService.NavigateModelAsync(PageNames.CustomerEditPage, Customer, true, false);
        });

This works as expected

Picker Control from CustomerEditPage.xaml

        <Picker ItemsSource="{Binding Locations}" 
                ItemDisplayBinding="{Binding LocationName}"
                SelectedItem="{Binding CustLocation, Mode=TwoWay}"
                SelectedIndexChanged="Handle_SelectedIndexChanged"/>

*Note that the SelectedIndexChanged was only set so I can see when it was firing

CustomerEditPage.xaml.cs

    public CustomerEditPage(CustomerEntry customer)
    {
        var vm = new ViewModels.CustomerEditViewModel(App.NavigationService);
        BindingContext = vm;

        if (customer != null || customer.ID > 0)
        {
            vm.EditCustomer = customer;
            vm.SetEditCustomer();
        }

        InitializeComponent();
    }

    void Handle_SelectedIndexChanged(object sender, System.EventArgs e)
    {
        //Testing to see if we get to this break-point
    }

As you can see, I take in the CustomerEntry class object. I check if it is not null and has an ID > 0 and if so passes to the ViewModel to set the controls. Again, the Handle_SelectedIndexChange is only fired for testing purposes (using a breakpoint).

CustomerEditViewModel.cs

    private CustomerEntry editCustomer;
    public CustomerEntry EditCustomer
    {
        get { return editCustomer; }
        set
        {
            editCustomer = value;
            OnPropertyChanged("EditCustomer");
        }
    }

    private ObservableCollection<CustomerLocation> locations = new ObservableCollection<CustomerLocation>();
    public ObservableCollection<CustomerLocation> Locations
    {
        get { return locations; }
        set 
        {
            locations = value;
            OnPropertyChanged("Locations");
        }
    }

    private CustomerLocation custLocation;
    public CustomerLocation CustLocation
    {
        get { return custLocation; }
        set
        {
            custLocation = value;
            OnPropertyChanged("CustLocation");
        }
    }

    public CustomerEditViewModel(INavigationService navigationService)
    {
        SubmitCommand = new Command(async () =>
        {
            await OnSubmit();
            await navigationService.NavigateModelAsync(PageNames.CustomerPage, null, true, true);
        });

        CancelCommand = new Command(async () =>
        {
            await navigationService.GoBack();
        });

        LoadLocations();
    }

    public async Task LoadLocations()
    {
        List<CustomerLocation> loadLocations = await App.Database.GetLocationsAsync();
        Locations = new ObservableCollection<CustomerLocation>(loadLocations);
    }

    public void SetEditCustomer()
    {
        ID = EditCustomer.ID;
        CustomerName = EditCustomer.CustomerName;
        CustLocation = new CustomerLocation() 
        { 
            LocationName = EditCustomer.LocationName
        };
        Email = EditCustomer.Email;
        Notes = EditCustomer.Notes;
    }

The EditCustomer, Locations and CustLocation properties all fire. Properties for ID, CustomerName,Email and Note omitted for brevity.

Locations are loaded from a SQLiteAsyncConnection (database is located on device)

CustomerLocation.cs

public class CustomerLocation
{
    public string LocationName { get; set; }
}

As mentioned above, I put a mock ID column in this class (I didn't actually designate it as a key now that I think about it - I am not sure if that makes a difference).

CustomerEntry.cs

public class CustomerEntry
{
    [PrimaryKey, AutoIncrement]
    public int ID { get; set; }

    public string CustomerName { get; set; }
    public string LocationName { get; set; }
    public string Email { get; set; }
    public string Notes { get; set; }
    public DateTime TimeStamp { get; set; }
}

CustomerEntry class here for reference purposes.

Xamarin - PCL/iOS/UWP/Droid - MT4118 & MT4116

$
0
0

Hi

I've got a solution implementing functions for various types of projects (iOS, Android, UWP) with multiple binding objects.

The criteria is:
We have implemented connections with various devices which have different versions. Each project can implement different version for a device and therefor we have a binding library for each part (plugin)

Then we have a factory for each, e.g. for iOS, where we have few plugins that can be selected from. When building the iOS app however we get an error because there can only be one instance of a library of the same type.
Isn't it possible to have multiple versions? Since they are all in a separate namespace

Plugin 1
v1.plugin.iOS.Project;
v1.plugin.Droid.Project;
v1.plugin.BindingLibrary.iOS; (Device v1)
v1.plugin.BindingLibrary.Droid

Plugin 2
v2.plugin.iOS.Project;
v2.plugin.Droid.Project;
v2.plugin.BindingLibrary.iOS; (Device v2)
v2.plugin.BindingLibrary.Droid

In this setup Plugin 1 is bound to use v1 of the same device Plugin 2 is using, but Plugin 2 uses version 2, which is crucial for solution the setup.

The error when building the iOS project and loading to a tablet:
MTOUCH : error MT4116: Could not register the assembly 'Binding1': error MT4118: Cannot register two managed types ('Binding1.iBPBitmapContext, Binding1' and 'Binding2.iBPBitmapContext, Binding2') with the same native name ('iBPBitmapContext').

Xamarin libraries to generate gif programmatically

$
0
0

Dear Forum

I am building a mobile app using Xamarin for an accident detection system, and i want to be able to achieve the below:

I want to be able to create a GIF using elements such as direction of vehicle, user input of speed of vehicle, angle of vehicle , etc to animate the collision between two cars. Thus i want to be able to Animate car A to move towards Car B using the elements i mentioned and then on supplying the parameters, a GIF can be generated showing the collision between two cars

Please are there any libraries that can help me generate a GIF programmatically without having to provide images of the accident etc...

Android Themes: Xamarin.Forms change the color of selected ListView item

$
0
0

So I want to swap out Blue in holo light theme to Orange. I've used this Holo Generator quite a few times with good results in normal Android apps.. but the "ListView" in Xamarin.Forms seems to render it with the old theme? All other aspects of Xamarin.Forms picks up the coloring. I went with themeing because Xamarin.Forms doesn't seem to support changing the color of the selected list item.

Is there a way with the databinding/templates to tell a ListView it's selected resource/color programatically?

How can i create Keystore for Android publish to Play Store?

$
0
0

How can i create the Key store.Is it require any credentials from the organization?


Cannot keep ListView ordered/sorted when navigating away and back

$
0
0

Hello!

I'm learning the ListView control and sorting data it shows, but i can't seem to fix a scenario.
I am using Visual Studio 2017 Community.

I am trying to have a list always ordered by this criteria:

  • column create date (DateTime.Now)
  • order descending

The following 3 scenarios must work with the same order criteria applied, but i can't seem to make it work for the 3rd one.
1) (working) When i open the app the 1st time (done with sorting in overriden Init method
2) (working) When i add items in the list (enter/done/verify on a specific Entry control adds to my ListView an item)
3) (not working) When, while the app is running , i navigate to another Page and back to the one that keeps this ListView

1) was solved with overriding Init method of the viewModel (which keeps the ObservableCollection prop)
2) was solved by using ObservableCollection.Insert(,item) instead of ObservableCollection.Add()
3) In the view, i tried overriding OnAppearing

In XAML:
<ListView
x:Name="ItemListView"
ItemsSource="{Binding Items}"
CachingStrategy="RecycleElement"

            HorizontalOptions="CenterAndExpand"
            VerticalOptions="CenterAndExpand"

            >
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout
                            Spacing="10"
                            Orientation="Horizontal"
                            >
                            <StackLayout>
                                <Label
                                    Text="{Binding Code}"
                                />

                                <Label
                                    Text="{Binding Description}"
                                />
                            </StackLayout>

                            <Label
                                Text="{Binding Number}"
                                FontAttributes="Bold"
                                VerticalOptions="Center"
                            />
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

In code-behind of View:

protected override async void OnAppearing()
{
base.OnAppearing();
await _itemViewModel.SaveItem(); //does some SQLite work related to Items
_itemPageViewModel.SortItems();
ItemListView.ItemsSource = _itemViewModel.Items;
}

In View-Model:
internal void SortItems()
{
Items.OrderByDescending(x => x.CreateDate);
}

However, when i repeatedly exit the Page and reenter, the items are unsorted.

Firebase stuck at verifying app

$
0
0

Hey all,

I am currently facing an issue with our app implementing firebase. It's stuck at the 4th step:

  1. Checking if the app has communicated with our servers. You may need to uninstall and reinstall your app.

I have chosen to skip this step for now and follow these guides:

  1. https://docs.microsoft.com/en-us/xamarin/android/data-cloud/google-messaging/remote-notifications-with-fcm?tabs=windows
  2. https://docs.microsoft.com/en-us/azure/notification-hubs/xamarin-notification-hubs-push-notifications-android-gcm

I am capable of sending a notification to the specific device and I do receive a firebase registration token. This does work, but somehow when I finish composing the message it won't trigger anything inside my app.

Second of all when sending a message within the azure portal it also receives a message. So the application endpoints seem to connect. (last part of guide 2).

Does someone know why it's not communicating with the servers?

Thanks in advance!

Is the Geofence API limited to push notifications? Or can it ping my server via REST API, while in t

$
0
0

I'm in the process of designing a mobile Xamarin app and would like to know if both iOS and Android devices can monitor GPS in the background for geofence entry/exit, and then ping my web servers via REST API.

The app will be run in the background by truck drivers, and their dispatcher will receive a notification on their web-based dashboard when the truck driver enters a particular geofence.

I am looking at the CrossGeeks API as of now, but have no preference which one to use.

All of the samples I've found online send push notifications OnEntry or OnExit. None have examples or mentions of sending updates to a server.

My question is: Can I use the GeoFencing API to wake up my app that's running in the background and send a notification to my server that it's entered a particular geofence?

Thanks in advance.

Is the GeoFence API limited to push notifications? Or can it ping my server via REST API, while in t

$
0
0

I'm in the process of designing a mobile Xamarin app and would like to know if both iOS and Android devices can monitor GPS in the background for geofence entry/exit, and then ping my web servers via REST API.

The app will be run in the background by truck drivers, and their dispatcher will receive a notification on their web-based dashboard when the truck driver enters a particular geofence.

I am looking at the CrossGeeks API as of now, but have no preference which one to use.

All of the samples I've found online send push notifications OnEntry or OnExit. None have examples or mentions of sending updates to a server.

My question is: Can I use the GeoFencing API to wake up my app that's running in the background and send a notification to my server that it's entered a particular geofence?

Thanks in advance.

Performance...

$
0
0

I am a newcomer to this forum and using c# with Xamarin so forgive me if my question is a little naïve.

I want to build my first app and interface to it a backend system for it's data and business processing. The backend has been written over the years in VB.NET and is very very stable.

Last week I asked a question about linking a Xamarin project to a VB class library which appears to be a non starter so I decided to re-write some of the VB class library into a c# class library.

I completed the conversation of the first couple of routines and decided to test. AND IT WORKED.

BUT at a price. to ensure a the module was properly tested I subject to 1 million operations. This is not unusual for testing and some VB routines have been tested with over a Billion operations. Some may argue this is excessive, but that's subjective and not really this point of this question.

What surprised me about the test was it was visibly slow. The 1 million operations actually took 42 seconds. I therefore decided to copy the methodology and create the same test using the original VB routines. That test took just 7 seconds to complete the 1 million operations.

Now I know I am no where near as accomplished C# programmer as I am VB so I can understand I perhaps didn't code like someone who has been using c# for a long time, but its a BIG difference.

So my question is:

Is this performance difference to be expected? Please consider the routines are in a class library (c# and VB) and invoked via a console app in both cases so near identical and both are running in debug mode.

Thanks in advance for your thoughts.

Alternative maps for Xamarin.Forms.Maps

$
0
0

In android when you register the api for maps, It required a link to a billing account to work, Is there another way to do it?

ref: docs.microsoft.com/en-us/xamarin/android/platform/maps-and-location/maps/obtaining-a-google-maps-api-key?tabs=vswin#connect-the-project-to-a-billable-account

What is the best place to pre-process data before any UI is initialized?

$
0
0

I want to process the data in a database before any UI pulls the data from it through View Model. Since async / await operations involved, which is the best place to pre-process data?

I find doing it in OnAppearing() is not meeting my requirement and I have to pull to refresh the ListView.


Basic Deployment and Build Questions

$
0
0
  1. I create a new project (Xamarin, Blank project). I compile it. My Android phone is plugged into the computer. I start the ADB server. Then I select Deploy and I get a deployment to the Emulator. I don't want that. I want to deploy to the phone. What gives? How do I diagnose? How do I stop deployment to the emulator?

How to use Windows like filesystem action on Mac?

$
0
0

Hello,

Here is my issue: I have an application using an old mono version (4.4.1) on an old ide (Xamarin 6.0.1) and some Windows internal calls such as FindNext or GetFileStats. These are InternalCall methods that I need to run my application.

I have updated everything to their last version, so I am now using Visual Studio for Mac 2017 and Mono 5.18.0.249 (with their associated XamMac.dll).
When I start the application, it says that FindNext or FindFirst method is not found anymore (Missing method exception) and that my mono build is sort of broken.

So how do I replace these methods?
I need methods that give me the stats of a file (if it's hidden, etc), ones that get the next file in line in a ptr, or the first in a folder, etc.
Such as found on Windows .Net.

If anyone knows I am all ears :smile:

If I was not clear, tell me, I will try to explain the situation better.

Struggling to compile application in 64bit on Xamarin

$
0
0

Hello,

I have an old version of Xamarin Studio running (6.0.1), with mono 4.4.1, 64bits, on a 64bits OS (10.11.5).
I have an application that is currently used by clients and compiled on 32bits. But with the upcoming deprecation of the 32bits on future MacOS, I have to create a 64bits application.

Problem is, even though I put all my projects compilers into 64bits, put them into an AnyCPU configuration, and compile all of that, the OS tell me the application is not in 64bits...(I am looking into the System report of the OS, and the applications listed in there).

Did I miss something? Is there something else than putting the compiler to be specifically x64 on each and every projects of the solutions?

Tell me if you need more information.

Reproduce carousel view behaviour/animation/transition to a horizontal scroll view.

$
0
0

Hey developers,
I have so far tried to use a carousel view due to its ease of use and of course its performance. But I tried to show the tail of each UI elements (let's say we've a bunch of cards) whatever the position is as shown in the picture. I've googled a lot and posted another question in this forum but since then I changed the project UI a little bit so I ignored the given solution and now I am on my own again, I resolved it (show the next card's tail or/and the previous), I'll write down the structure I used in XAML but first let me highlight my requirements.
I want to reproduce the behaviour, animation/transition on swiping of the carousel view to my view, because I am actually using a horizontal scroll view with a Flex layout inside.
Here is the structure :

Now I've tried two options :
1- Use of Scrolled event in the scroll view but that hasn't been a great option because it fire the events (animation or transition) after the scroll is done, in my case it should fire the event since scrolling started.
2- Use of SwipeGestureRecognizer on Scrollview, FlexLayout and BoxView : couldn't get a stable behaviour on the 2 first attempts but when I used a BoxView I couldn't get each StackLayout (the StackLayout is my card) inside the BoxView (It wasn't built for that).

Here is my UI after I used a horizontal scroll view :

here is the behaviour I wanted to reproduce to my view :
https://media.giphy.com/media/l0NwH3XDSYhQ6l4TC/giphy.gif

Statically registering a Broadcast Receiver - A working example

$
0
0

Hello there

I wan't to statically register a Broadcast Receiver and I have followed the guidelines at
https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/broadcast-receivers

As I understand we do not register the Broadcast Receiver directly in the Android Manifest file, but instead we decorate our receiver as following

[BroadcastReceiver(Enabled = true)]
[IntentFilter(new[] { "com.xamarin.example.TEST" })]
public class MySampleBroadcastReceiver : BroadcastReceiver
{
    public override void OnReceive(Context context, Intent intent)
    {
        Console.WriteLine("Hurray it works"!);
    }
}

Then the receiver should be able to pick up on the following broadcast

Intent message = new Intent("com.xamarin.example.TEST");
SendBroadcast(message);

However I do not receive this intent. I only receive the intent, when I register the receiver within the context as following

RegisterReceiver(new MySampleBroadcastReceiver(), new IntentFilter("com.xamarin.example.TEST"));

Have I misunderstood something or am I missing some steps? Any help would be appreciated.

Why do I need this?
My goal is to launch notifications at particular timestamps defined by the user. I've context-registered a broadcast receiver, that issues a notification, when an intent is received. The Android Alarm Manager is used to broadcast the intent at a particular time.
As the broadcast receiver is context-registered it will not receive intents, when the app has been killed (when the app is swiped in the recent applications menu). I want the notifications to keep coming when the app has been swiped.

Viewing all 204402 articles
Browse latest View live


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