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

Print receipt via POS printer

$
0
0

I'd like to know, can I print receipt via POS (bluetooth - thermo) printer with Xamarin. How I can solve this problem. Thanks before for reply.


Play Services Version vs Nuget Package Build Version

$
0
0

It looks like the latest Google Play Service version is 11.6; however, the nuget package for Xamarin.GooglePlayServices is 42. Is there a document that can show how these versions are related?

Azure search is not working with typeahead functionality.

$
0
0

Hello guys, I have implemented azure search for searching workspaces from database which I have imported in azure. The issue is when I give a request call for searching the results, it has some time delay into it. My requirement is that I need a flawless azure search without hanging user for every work he types in the Entry field.

private async void SearchEntryTextChanged(object sender, TextChangedEventArgs e)
{
var entry = sender as CustomEntry;
string searchedString = entry.Text;
if (searchedString.Length > 2)
{
_workspaceSearchService = new AzureWorkspaceSearchApi();
List workspaceSearchData = new List();
//workspaceSearchData = await _workspaceSearchService.SearchWorkspaceFromAzure(searchedString);
workspaceSearchData = await _workspaceSearchService.ExecSuggest(searchedString);

               viewModel.SearchWorkspaceRecord = workspaceSearchData;
           }

}

For every character that enter after 2 length I am calling azure search. This request needs some time to get completed and hangs the user until it gets search result. I need these request to be done using typeahead phenomenon. Can anyone suggest me a solution to achieve this?

Below is the azure request:-

public async Task<List> ExecSuggest(string q)
{
try
{
// Execute /suggest API call to Azure Search and parse results
//string url = _serviceUri + AzureSuggestUrl + q;
string url = "https://meelosearchbasic.search.windows.net/indexes/indworkspacesearch/docs/suggest?api-version=2016-09- > >01&suggesterName=sgworkspacesearch&$top=5&$filter=TenantId eq '" + App.userTenantId + "'&search=" + q;
_httpClient = new HttpClient();
Uri uri = new Uri(url);
List Suggestions = new List();

           HttpResponseMessage response = AzureSearchHelper.SendSearchRequest(_httpClient, HttpMethod.Get, uri);
           AzureSearchHelper.EnsureSuccessfulSearchResponse(response);

           var obj = JsonConvert.DeserializeObject<SearchResult>(response.Content.ReadAsStringAsync().Result);
           Suggestions = obj.value;

           return Suggestions.Distinct().OrderBy(x => x.SearchText).ToList();
       }
       catch(Exception e)
       {
           return null;
       }
   }

UWP application only occasionally launches

$
0
0

I've been developing a UWP, Android, and iOS application.

The UWP had been working fine, then after my latest upgrade to 15.5, the UWP app launch has been erratic.

When I first start Visual Studio, the UWP app launches in debug mode just fine. I close it, make a minor change, then relaunch.

I can see the app flicker on the screen, extremely briefly. No errors in the build process at all.

If I close Visual Studio and reopen it, then the UWP will launch. Once only. I have to shutdown and restart Visual Studio between each UWP launch.

Again, there are absolutely no errors anywhere.

3>Creating a new clean layout...
3>Copying files: Total 32 mb to layout...
3>Checking whether required frameworks are installed...
3>Registering the application to run from layout...
3>Deployment complete (0:00:00.982). Full package name: "MyApp_1.0.3.0_x86__p0vm33n94x0y0"

Xamarin Forms Bluetooth

$
0
0

Hi,
I am trying to create a Portable Class library Xamarin Form project in which I need to use Bluetooth of the device to communicate with HC-05 Bluetooth module using serial communication. I want the code to be cross-platform. Can anybody please guide me step by step how can I do a single coding for both Android and iOS platform in Xamarin Forms. I don't want to opt for platform-specific coding. Thanks in advance

No exception details when debugging on android

$
0
0

When I debug my Xamarin.Forms app on UWP and an exception occurs, the application breaks on the line that the exception is thrown, showing me the exception details, the call stack, and allows me to inspect local variables. However, on android, every single time an exception occurs, I get this extremely unhelpful error:

The application is in Break Mode
Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code).
An unhandled exception occurred

There are zero details about the exception. No stack trace. No local variables. Nothing.
(Note to the mods: it's really dumb that I'm not allowed to post a screenshot of this because I haven't been on the forums long enough)

Note, if I follow the exact same steps to reproduce any of these exceptions in UWP, the application breaks correctly on the exception and I am able to see the details. It is only in android that I get this useless page with no information.

I've tried adding unhandled exception handlers in my MainActivity, and added breakpoints, but when an exception occurs, the breakpoints never get hit and I still encounter the same useless error page:

[Activity(Label = "Redacted", Icon = "@drawable/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)
    {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;

        base.OnCreate(bundle);

        global::Xamarin.Forms.Forms.Init(this, bundle);
        global::Xamarin.FormsMaps.Init(this, bundle);
        AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;
        AndroidEnvironment.UnhandledExceptionRaiser += HandleAndroidUnhandledException;
        LoadApplication(new App());
    }

    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
    {
        PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
    }

    private static void HandleUnhandledException(object sender, UnhandledExceptionEventArgs args)
    {
        ErrorHandler.HandleException(args.ExceptionObject as Exception);
    }

    private static void HandleAndroidUnhandledException(object sender, RaiseThrowableEventArgs args)
    {
        ErrorHandler.HandleException(args.Exception);
    }
}

The following is in my Xamarin.Forms assembly:

public static class ErrorHandler
{
    public static void HandleException(Exception e)
    {
        #if DEBUG
            System.Diagnostics.Debugger.Break();
        #endif
        Application.Current.MainPage.DisplayAlert(e.GetType().Name, e.Message, "OK");
    }
}

I've also tried both with an emulated device and with a real device, and the same thing happens either way.

Why am I not seeing useful exception information when debugging on android? Is there something I can do in order to stop seeing this useless "The application is in Break Mode" message?

Updating Xamarin from source on Windows

$
0
0

I'd like to update my version of xamarin to this build: ...github.com/xamarin/xamarin-macios (cant post links)

however I'm using a windows machine so make doesn't work -

More specifically this is the file I need to update: ...github.com/xamarin/xamarin-macios/blob/2b1e34caa4fba0086ef863278caff4ae5a1f1fa2/src/Foundation/NSUrlSessionHandler.cs

I've attempted to do so via Visual Studios by going to the definition, but this only open metadata (I've tried adding and removing xamrin as a reference and a lot of other things, I don't think it'll work because I'm referencing a dll)

How can I compile this build on windows?

UrhoSharp with Proper UWP support (x64 + Release)

$
0
0

I've been working on a desktop software project using Xamarin Forms / UWP / UrhoSharp and when we started we came to the conclusion that Microsoft was pushing Urho as their cross platform 3D library and were actively working on it. Our hope was that since UWP was their native platform Urhosharp would be top priority. It's been many months and unfortunately 64 bit and Release builds are still not working for UWP.

Since this is a big priority for us I've grabbed the latest xamarin/urho code to build the library manually, and try and get proper support so the rest of the community could benefit as well. The problem I'm seeing is that in the code there is a pre-built SDL2 (x86/debug) library that is being used in the UWP builds. For me to move forward would someone be able to provide the proper source+configuration for this library so I could build it myself?

@EgorBo @MigueldeIcaza If you could offer any help I could certainly be willing to put in the time to move this project forward.

Thanks for all your help!


Are shadows enabled?

$
0
0

I'm studying Urhosharp and I find it great.

I have now a problem with shadows.
I've downloaded the Samples and for example I see that the shadows are there (Physics example).
If I copy the example in a Xamarin Forms Urhosharp project, then the shadows disappear (Tested on UWP and Android).

The code is exactly the same (Physics demo).
Am I doing something wrong or the shadows are not available in a Xamarin Forms project?

Thanks

Xamain App installed in MobileIron - crash will launching

$
0
0

Created an corporate app and first time trying to install in MobilIron, initially not able to install/download. With some changes in entitlement file by deployment team able to install the app now to the iphone. But not able to launch / open the app, it crashes / terminates while launching. Is there is any way to find out the issue ? or How should we fix this issue ? Please advise.

Keeping VS/XCode versions in sync?

$
0
0

Is it best practice, when updating VS on Windows, to also update VS on the Mac as well as XCode? Would there be any issues if you just updated VS on both platforms but not XCode? What's the ideal way of keeping everything in sync? I ask because the 15.5 VS release doesn't yet support XCode 9.2 (at least when it comes to the remoted simulator) so going forward, I wanted to make sure I do my updating the right way. Thanks!

Remove separator beneath ListView GroupHeaderTemplate?

$
0
0

Is there any way to remove the separator beneath the ListView group headers?

image

I'm not doing anything special in the DataTemplate.

  <ListView.GroupHeaderTemplate>
    <DataTemplate>
      <ViewCell
        Height="45">
        <StackLayout
          BackgroundColor="White"
          VerticalOptions="FillAndExpand"
          HorizontalOptions="FillAndExpand">
          <StackLayout
            VerticalOptions="CenterAndExpand"
            Margin="15, 0, 5, 0">
            <Label
              Text="{Binding LongName}" />
          </StackLayout>
        </StackLayout>
      </ViewCell>
    </DataTemplate>
  </ListView.GroupHeaderTemplate>

Xamarin.Forms Google API Authenticating Users with an Identity Provider

$
0
0

I am still getting used to Xamarin.Forms and I am on very basic level. I went through many articles for my issue, but to the end couldn't resolve it. So...

Currently I am trying to add Google authentication inside my Xamarin.Forms application, which use Droid and iOS (no WP). So far I am following guide from here. I am using Xamarin.Auth to authenticate to Google.

Here is some part from my source code.

The problem is coming after my method complete it's work. So after my last line:

presenter.Login(authenticator);

everything looks alright and debugging I am following that compiler goes out of method without any errors, but then I receive exception, which you can see here. It's "No compatible code running".

Here some more information regarding my source code:

  • Source of "Constants" class used for client ids and URLs
  • Source of implemented methods for on authentication complete/error, which in fact still I cannot hit because of my error
  • Source of Android MainActivity where I added

global::Xamarin.Auth.Presenters.XamarinAndroid.AuthenticationConfiguration.Init(this, bundle);

Source of UrlSchemeInterceptorActivity
Here are the main articles I went through deeply => Link 1, Link 2 and Link 3, but still couldn't resolve the issue.

I am not sure where the error comes from, or can I can I continue debugging it to resolve issue.

Thanks in advance

WEB API service fails with 3g/4g but fine with WIFI.

$
0
0

Hi,

I am developing Xamarin.Forms (PCL) application and I have created separate PCL to consume Web API using HttpClient.
I am able to consume Web API through WIFI but not able to consume with 3g/4g.
Below is sample code.

HttpClient client;

async public Task<List> GetPatientAsync()
{
client = new HttpClient();
client.MaxResponseContentBufferSize = 256000;

        List<Patient> responseData;
        var uri = new Uri(Constants.PatientUrl);
        try
        {

            var response = await client.GetAsync(uri.AbsoluteUri);

            if (response.IsSuccessStatusCode)
            {
                var jsonString = await response.Content.ReadAsStringAsync();
                responseData = JsonConvert.DeserializeObject<List<Patient>>(jsonString);
            }
            else
            {
                responseData = new List<Patient>();
            }
        }
        catch (Exception ex)
        {
            responseData = new List<Patient>();
        }
        return responseData;
    }

Please help.

Thanks

Need help: Warning The "ResolveLibraryProjectImports" task failed unexpectedly.

$
0
0

Severity Code Description Project File Line Suppression State
Warning The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'apl, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'apl.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection1 jars, ICollection1 resolvedResourceDirectories, ICollection1 resolvedAssetDirectories, ICollection1 resolvedEnvironments)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() apl.Android


Device contact is not getting updated

$
0
0

Hi,

I have a Xamarin.Forms based application which uses operation with device contact like adding new contact, updating existing contact. Adding new contacts works, but update contact is not working. First i searched for that contact and get its' Id if it exist.
Below is my code

string LookupByPhone(string phoneNumber, string query = "")
    {
        var Id = "0";
        try
        {
            var context = MainActivity.Instance;

            var uri = ContactsContract.Contacts.ContentUri;
            uri = ContactsContract.CommonDataKinds.Phone.ContentUri;

            string[] projection = {
                ContactsContract.Contacts.InterfaceConsts.Id,

                InterfaceConsts.DisplayName,
                ContactsContract.CommonDataKinds.Phone.Number
                };

            var cursor = context.ContentResolver.Query(uri, projection, null, null, null);

            if (cursor.MoveToFirst())
            {
                do
                {
                    var id = cursor.GetString(cursor.GetColumnIndex(projection[0]));
                    var nm = cursor.GetString(cursor.GetColumnIndex(projection[1]));
                    var number = cursor.GetString(cursor.GetColumnIndex(projection[2]));

                    Id = id;
                    if (nm == query)
                        break;

                    //break;
                } while (cursor.MoveToNext());
            }
            cursor.Close();
        }
        catch (Exception ex)
        {
            LogController.LogError(ex);
        }
        return Id;
    }



void UpdateContact(string phonenumber, string id, string givenName, string familyName)
    {
        ContentProviderOperation.Builder builder = ContentProviderOperation.NewUpdate(ContactsContract.Data.ContentUri);


        List<ContentProviderOperation> ops = new List<ContentProviderOperation>();

        if (!string.IsNullOrWhiteSpace(givenName) && !string.IsNullOrWhiteSpace(familyName))
        {
            // Name
            String nameSelection = ContactsContract.Data.InterfaceConsts.ContactId + " = ? AND "
                                   + ContactsContract.Data.InterfaceConsts.Mimetype + " = ? ";
            String[] nameSelectionArgs = {
                                            id.ToString(),
                                            ContactsContract.CommonDataKinds.StructuredName.ContentItemType
            };


            builder.WithSelection(nameSelection, nameSelectionArgs);
            builder.WithValue(ContactsContract.CommonDataKinds.StructuredName.GivenName, givenName);
            builder.WithValue(ContactsContract.CommonDataKinds.StructuredName.FamilyName, familyName);
            builder.WithValue(ContactsContract.CommonDataKinds.StructuredName.DisplayName, givenName + " " + familyName);

            ops.Add(builder.Build());
        }

        #region Phone update
        // CellPhone
        String phoneSelection = ContactsContract.Data.InterfaceConsts.ContactId + " = ? AND " +
                                   ContactsContract.Data.InterfaceConsts.Mimetype + " = ? AND " +
                                   ContactsContract.CommonDataKinds.Phone.InterfaceConsts.Type + " = ?";

        String[] phoneselectionArgs = {
               id.ToString(),
                   ContactsContract.CommonDataKinds.Phone.ContentItemType,
               PhoneDataKind.Mobile.ToString()
            };

        builder = ContentProviderOperation.NewUpdate(ContactsContract.Data.ContentUri);
        builder.WithSelection(phoneSelection, phoneselectionArgs);

        builder.WithValue(ContactsContract.CommonDataKinds.Phone.Number, phonenumber);
        builder.WithValue(ContactsContract.CommonDataKinds.Phone.InterfaceConsts.Type, PhoneDataKind.Mobile.ToString());
        ops.Add(builder.Build());
        #endregion

        // Update the contact
        ContentProviderResult[] result;
        try
        {
        // the result return count{0}
        var result = MainActivity.Instance.ContentResolver.ApplyBatch(ContactsContract.Authority, ops);

        }
        catch (Exception ex)
        {
            LogController.LogError("Error updating phone:" + phonenumber,ex);
        }
    }

There are no error or exception. Any thought on this?

How to manage app localization ?

$
0
0

Hi,

What are the guidelines to manage apps localization using Xamarin.Forms ?
Each platform has its own localization process (RESX on WP, XML on Android, etc.) so how to do that localization part on the main Xamarin.Forms project of a solution?

Thanks!

How to add/modify listener for physical buttons?

$
0
0

I have an application that contains a listview of parts. I would like to be able to navigate up and down the listview using the volume up/down keys. Currently, I have an EditText item that displays the selected part. When I press the volume up/down button, the value in the EditText field is changing, so the mapping part appears to be working; however, I would like to eventually remove the EditText field and highlight the selected listview item (as it does in touch event). Is there a way to borrow the touch event listener for the volume up/down buttons so I can change the color of the selected item?

How to render Facebook-Button?

$
0
0

Hello, I would like to know how to render the facebook-login button from this SDK:

https://components.xamarin.com/view/facebookios

Creating the button in AppDelegate does not work (does not rendered in the storyboard and throws an exception in Main.cs)

 `LoginButton  loginButton = new LoginButton (new CGRect (48, 0, 218, 46)) {
     LoginBehavior = LoginBehavior.Native,
  };`

Unable to update NeGet packages to v26.02

$
0
0
  1. Use the latest version of VS2017.
  2. Start a blank Xamarin Forms project in the simplest form.
  3. Go to NuGet to manage packages.
  4. 16 v26.02 Android packages need to be updated.
  5. Updating results in the following errors:

Attempting to gather dependency information for package 'Xamarin.Android.Support.Animated.Vector.Drawable.26.0.2' with respect to project 'AppXamarinFormsDebug.Android', targeting 'MonoAndroid,Version=v7.1'
Gathering dependency information took 1.35 sec
Attempting to resolve dependencies for package 'Xamarin.Android.Support.Animated.Vector.Drawable.26.0.2' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'Xamarin.Android.Support.Animated.Vector.Drawable.26.0.2'
Resolved actions to install package 'Xamarin.Android.Support.Animated.Vector.Drawable.26.0.2'
Retrieving package 'Xamarin.Android.Support.Animated.Vector.Drawable 26.0.2' from 'nuget.org'.
Retrieving package 'Xamarin.Android.Support.Design 26.0.2' from 'nuget.org'.
GET https://www.nuget.org/api/v2/package/Xamarin.Android.Support.v7.MediaRouter/26.0.2
Retrieving package 'Xamarin.Android.Support.v7.AppCompat 26.0.2' from 'nuget.org'.
GET https://www.nuget.org/api/v2/package/Xamarin.Android.Support.Design/26.0.2
Retrieving package 'Xamarin.Android.Support.v7.MediaRouter 26.0.2' from 'nuget.org'.
Removed package 'Xamarin.Android.Support.Animated.Vector.Drawable.25.4.0.2' from 'packages.config'
OK https://www.nuget.org/api/v2/package/Xamarin.Android.Support.Design/26.0.2 127ms
OK https://www.nuget.org/api/v2/package/Xamarin.Android.Support.v7.MediaRouter/26.0.2 134ms
Installing Xamarin.Android.Support.v7.MediaRouter 26.0.2.
Installing Xamarin.Android.Support.Design 26.0.2.
Successfully uninstalled 'Xamarin.Android.Support.Animated.Vector.Drawable.25.4.0.2' from AppXamarinFormsDebug.Android
Removed package 'Xamarin.Android.Support.Design.25.4.0.2' from 'packages.config'
Successfully uninstalled 'Xamarin.Android.Support.Design.25.4.0.2' from AppXamarinFormsDebug.Android
Removed package 'Xamarin.Android.Support.v7.AppCompat.25.4.0.2' from 'packages.config'
Successfully uninstalled 'Xamarin.Android.Support.v7.AppCompat.25.4.0.2' from AppXamarinFormsDebug.Android
Removed package 'Xamarin.Android.Support.v7.MediaRouter.25.4.0.2' from 'packages.config'
Successfully uninstalled 'Xamarin.Android.Support.v7.MediaRouter.25.4.0.2' from AppXamarinFormsDebug.Android
Install failed. Rolling back...
Package 'Xamarin.Android.Support.Animated.Vector.Drawable.26.0.2' does not exist in project 'AppXamarinFormsDebug.Android'
Package 'Xamarin.Android.Support.v7.MediaRouter.25.4.0.2' already exists in folder 'E:\Xamarin\packages'
Added package 'Xamarin.Android.Support.v7.MediaRouter.25.4.0.2' to 'packages.config'
Package 'Xamarin.Android.Support.v7.AppCompat.25.4.0.2' already exists in folder 'E:\Xamarin\packages'
Added package 'Xamarin.Android.Support.v7.AppCompat.25.4.0.2' to 'packages.config'
Package 'Xamarin.Android.Support.Design.25.4.0.2' already exists in folder 'E:\Xamarin\packages'
Added package 'Xamarin.Android.Support.Design.25.4.0.2' to 'packages.config'
Package 'Xamarin.Android.Support.Animated.Vector.Drawable.25.4.0.2' already exists in folder 'E:\Xamarin\packages'
Added package 'Xamarin.Android.Support.Animated.Vector.Drawable.25.4.0.2' to 'packages.config'
Package 'Xamarin.Android.Support.Animated.Vector.Drawable.26.0.2' does not exist in folder 'E:\Xamarin\packages'
Executing nuget actions took 53.12 sec
Could not install package 'Xamarin.Android.Support.Animated.Vector.Drawable 26.0.2'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v7.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Time Elapsed: 00:00:54.6190348
========== Finished ==========

Viewing all 204402 articles
Browse latest View live


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