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

xamarin.auth vs xamarin.auth.xamarin forms package?

$
0
0

What is the difference between these 2 packages? I cant find any information or sample about xamarin forms named package. does it work on native level and all we should do is in shared project? is there any good sample usage of this package please?


How to implement an Android Service in Xamarin.Forms

$
0
0

Hi! I have an application and I want to periodically check from a web service if an item has been added to a table on a database, the new item should be added to the listview the user sees.
I'm using PCL and I did accomplish it creating a new Task and then with a timer checking every specific time but I want it to work if the app is closed too, the user should get a notification that a new item has been added.
So I was doing some research and I came across android services, the info said that the service will continue, regardless of the app state, until you tell it to stop. But I haven't found many examples and I don't know how to implement the code that I already had to the service.

This is the code that I had

              Task.Run(() =>
                        {
                            Device.StartTimer(TimeSpan.FromSeconds(secs), checkUpdates);
                        });


bool checkUpdates()
          {
            if (isOnline)
            {
                var lastUp= Application.Current.Properties["lastUpdate"] as string;

    //the method returns a true if an item has been added
                if (service.NewItem(DateTime.Parse(lastUp)))
                {
                    var it = service.getNewItem(DateTime.Parse(lastUp));

                    Device.BeginInvokeOnMainThread(() =>
                    {    
                            notification.ShowNotification(it.Title, 1000);
                            listView.Insert(0, it);
                     }                            
                    });                  
                }
                App.Current.Properties["lastUpdate"] = DateTime.Now.ToString();
            }
            return true;
        }

This is the code that works when the app is open, and I'm trying to use dependecy services to consume the service in my PCL. Here's what I've got so far:

     public interface IService
        {
            void Start();
        }

      [Service]
        public class DependentService : Service, IService
        {
            public void Start()
            {
                var intent = new Intent(Android.App.Application.Context, typeof(DependentService));
                Android.App.Application.Context.StartService(intent);
            }

            public override IBinder OnBind(Intent intent)
            {
                return null;
            }

            public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
            {
                // From shared code or in your PCL


                return StartCommandResult.NotSticky;
            }
        }

The problem is that I don't know how to implement the same code that I had in the timer here. Can someone please help?

How to implement an Android Service

$
0
0

Hi! I'm trying to periodically check with a web service if a new item has been added to a database. If there's a new item a listview that the user sees should be updated.
I'm using PCL and I have accomplish it creating a new Task with a timer inside. But this only works if the app is open. I want to do the same when the app is closed so the user gets a notification when a new item is added remotely.
I've been doing some research and I found andoid services, the info said that the service will continue, regardless of the app state, until you tell it to stop. But i haven't found many examples in how to implement it.

Here's the code that I had that works only when the app is opened:

 Task.Run(() =>
            {
                Device.StartTimer(TimeSpan.FromSeconds(secs), checkUpdates);
            });

  bool checkUpdates()
          {
            if (isOnline)
            {
                var lastUp= Application.Current.Properties["lastUpdate"] as string;

        //returns true if a new item is added
                if (service.newItem(DateTime.Parse(lastUp)))
                {
                    var itm = service.getNewItem(DateTime.Parse(lastUp));

                    Device.BeginInvokeOnMainThread(() =>
                    {
                            notification.ShowNotification(itm.Title, 1000);
                            listView.Insert(0, itm);
                     }                        
                    });                  
                }
                App.Current.Properties["lastUpdate"] = DateTime.Now.ToString();
            }
            return true;
        }

I'm trying to do the same with an Android service using dependency services, here's what I've got so far:

     public interface IService
        {
            void Start();
        }

      [Service]
        public class DependentService : Service, IService
        {
            public void Start()
            {
                var intent = new Intent(Android.App.Application.Context, typeof(DependentService));
                Android.App.Application.Context.StartService(intent);
            }

            public override IBinder OnBind(Intent intent)
            {
                return null;
            }

            public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
            {
                // From shared code or in your PCL


                return StartCommandResult.NotSticky;
            }
        }

The problem is that I don't know how to implement the code that I had in the timer to the service, can someone please help?

WCF Async calls

$
0
0

Hi guys i have a question regarding WCF datacontracts and and handling larger payloads on the client (Xamarin Forms)
Currently my app reads Configuration data off the server with

            var setupdata2 = await Task.Factory.FromAsync<long, mynamespace.DTO.SetupData2>(
    svc.BeginGetSetupData2,
    svc.EndGetSetupData2,
     App.SiteID,
     null,
     TaskCreationOptions.None);

Where SetupData2 Is a collection of objects is need on the client.

The more payload data i add into these collections the longer i wait.

But it seems unreasonable that i have to wait in excess of 2 minutes for data that i have estimated to be in the region of 5mb of data.
When i debug the UWP app locally on my machine it goes a lot faster but it seems that on a real tablet (Android and Windows) It just takes forever to come back and end the async call to EndGetSetupData2.

What are my options for speeding this up .

And what is a good payload size to start splitting up into multiple requests?

Style FormsCommandBar

$
0
0

I have a Xamarin Forms app and in UWP I'd like to alter the colours of the ellipses button and secondary menu. I've been following the advice provided in another forum post (apparently, I'm not allowed to post links):

@MatthewR said:
If you want to change just the command bar's overflow background color you can change the FormsCommandBar style.

Add this style (copied from Xamarin's Source Code) to your app.xaml in your UWP project.
You can then edit the CommandBarOverFlowPresenter's background Color like this:

<Application xmlns:uwp="using:Xamarin.Forms.Platform.UWP"
. . .>
  <Style TargetType="uwp:FormsCommandBar">
  .
  .
  .
  <CommandBarOverflowPresenter x:Name="SecondaryItemsControl"
                               Background="<YourBackgroundColorHere>"
                               IsEnabled="False"
                               IsTabStop="False"
                               Style="{TemplateBinding CommandBarOverflowPresenterStyle}">
      <CommandBarOverflowPresenter.ItemContainerStyle>
          <Style TargetType="FrameworkElement">
              <Setter Property="HorizontalAlignment" Value="Stretch" />
              <Setter Property="Width" Value="NaN" />
          </Style>
      </CommandBarOverflowPresenter.ItemContainerStyle>
      <CommandBarOverflowPresenter.RenderTransform>
          <TranslateTransform x:Name="OverflowContentTransform" />
      </CommandBarOverflowPresenter.RenderTransform>
  </CommandBarOverflowPresenter>
  .
  .
  .
  </Style>
</Application>

I needed to do this to avoid changing action sheets and pickers background colors.

*Note: Make sure not to specify a x:key for the FormsCommandBar style or it won't work.

However, the style is not being applied. I put my style in the App.xaml resource dictionary. I'm using Xamarin Forms 2.5.0.280555.

Am I missing something?

Animation in Listview cell deletion

$
0
0

I've created a custom listview with multiple cells, and added a cross icon to each viewcell in the list. While clicking on the cross icon particular cell will be removed from the list. Can anyone please let me know if there is any method of implementing any animation or any transition to a single view cell on deletion?

Customized Tree view in Xamarin Forms

$
0
0

I'm following this plugin -github.com/danvanderboom/Xamarin-Forms-TreeView- for creating tree view but I'm not able to add plus and minus icon in tree view. The plus and minus icon should change as per the logic of ShowExpandCollapse property. Please help me with this ASAP. Your help will be appreciated.

symbologyname for scanned barcode?

$
0
0

i am using honeywell sl42 sled,i have included captuvo.dll to my app,able to fire follwing events getting rawdata for the scanned barcode
[Export("captuvoConnected")]
public void CaptuvoConnected()
{
}
[Export("captuvoDisconnected")]
public void CaptuvoDisconnected()
{
}
[Export("decoderRawDataReceived:")]
public void DecoderRawDataReceived(Foundation.NSData data)
{
}

But unable to get symbology name using below code,but this event is not getting fired
[Export("SymbologyName:")]
public string SymbologyName(Symbology symbologyname)
{
}

Thanks,
vijay


Reusable UI Widget

$
0
0

There are Pages, which can hold a variety of cross-platform views. Yet, there seems to be no way to isolate these and re-use them, ala .net controls. Isn't that the basic premise of reusable UI? I have scoured the internet, yet can find nothing after a couple years of tracing this. Am I missing something? Could someone point me in the right direction?

How to set the application to run in landscape mode only?

$
0
0

I have created a xamarin forms application which i want to run on windows 10 tablet only in landscape mode whether or not the deviceOrientation is on. I checked the checkBox of landscape and landscape-flipped in package.appxManifest but it still rotate in portrait mode. can anyone help me on this? How can I set my app to run in landscape?

"The application is in break mode" when use Map?

$
0
0

Hi everybody!
I'm working with Map in Xamarin.Forms
I have a button to navigate to MapPage. Android app crash and show "The application is in break mode" but UWP work fine?

Windows Phone UWP - Content is 'hidden' behind the Back/Home/Search button menu

$
0
0

I have a simple page with a grid view. The grid has two rows, the first has a height of *85, the second *15. However, the content in the second row is partially blocked by the Back/Home/Search buttons on the phone. Is this a bug? If not, what is a good way to work around this?

In case it matters, the content in the first row of the grid is a webview, and the content in the second row of the grid Is a horizontal stacklayout containing labels.

How can I change ViewCell height?

$
0
0

I have ViewCell in TableView, I need to put two buttons there:

                <ViewCell Height="100">
                    <StackLayout Margin="10,0">
                        <Button Text="Button 1" />
                        <Button Text="Button 2" />
                    </StackLayout>
                </ViewCell>

Height don't work. How can I change ViewCell's height?

OnAppearing of root page isn't fire after PopToRootAsync. Is it normal?

$
0
0

Hello. I have strange behavior. OnAppearing of root page isn't firing after PopToRootAsync and PopAsync. Is it normal or bug?
I think I solved this problem using messaging center, but I think it is not good solution.

How can I consume WCF service without Protable Class!

$
0
0

Hi,
As I know, right now we can't create project with Protable Class, so I don't know how to work with WCF. Anyone have a suggestion?


Getting Exception : Xamarin.Forms.Xaml.XamlParseException: Cannot assign property "Text"

$
0
0

Hi All,

I am Working on Multilingual functionality while i am binding my label with the Key , It is trowing Exception.
Please help Me.
`

<ContentPage.Content>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="100" />
            <RowDefinition Height="120" />
            <RowDefinition Height="200" />
            <RowDefinition Height="77" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="30" />
            <ColumnDefinition Width="280" />
            <ColumnDefinition Width="50" />
        </Grid.ColumnDefinitions>
        <StackLayout Grid.Row="1" Orientation="Vertical" Grid.Column="1">

            <Label Text="{translator:Translate OneApp}" TextColor="#FEFEFE" Font="15" HorizontalOptions="Center" VerticalOptions="Center" HorizontalTextAlignment="Center"></Label>
        </StackLayout>
    </Grid>
</ContentPage.Content>


`

Actuall working sample of Xamarin Form that does REST on Android

$
0
0

Can someone please provide an actual working sample of a Xamarin Forms project that also works with Android? We tried to use the TODORest Sample which initially wouldn't even build but after having downloaded the latest version from GitHub we at least got it to work. But communicate with the REST API just does not seem to work on Android (but does on UWP). There are numerous threads here and on other forums about similar problems with HttpClient, RestSharp etc.

Looking for a free DataMatrix writer

$
0
0

What the title says. The problem with ZXing is it writes only a low resolution DataMatrix which can't be upscaled.

NavigationPageRenderer - OnAttachedToWindow - Sequence contains no elements

$
0
0

We changed some code and now the Android app crashes on startup. This is what I got from the log:

Time Device Name Type PID Tag Message
07-26 10:14:26.356 LGE Nexus 5X Info 27331 MonoDroid System.InvalidOperationException: Sequence contains no elements
at System.Linq.Enumerable.Last[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00010] in :0
at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnAttachedToWindow () [0x00011] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:211
at Android.Views.View.n_OnAttachedToWindow (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <9ab9faae1b4b4f0da28e7c4ac61e2c78>:0
at (wrapper dynamic-method) System.Object:d392ac44-8ad7-4f92-9fdf-b7aceefc1fe7 (intptr,intptr)

I can see the code here:
https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs

But, I'm powerless to stop the bug or detect why it is occurring. Could someone at Xamarin please put a better validation error message in this method? Or, could someone please recommend a work around? This code works fine on UWP.

How to implement autobackup in xamarin android project?

$
0
0

I went through the official android documentation for auto backup for android 6 and higher. it says that only thing required is to add into the manifest but this doesnt work somehow for me or i dont know what I should expect with that.

<manifest ... >
    ...
    <application android:allowBackup="true" ... >
        ...
    </application>
</manifest>

For example, when I look at whatsapp, under my google drive, i can see whatsapp backup together with my phone name backup. So question is my app is backed up into my phones full backup or doing that I expect a separate backup like whatsapp.

2nd question, whatsapp has options to change gmail account, frequency etc. How can we do it for our app? implementing xamarin.auth with google login can help but which api is it to change settings for backup?

Viewing all 58056 articles
Browse latest View live


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