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

failed to open APK: Iteration ended.

$
0
0

I'm working in Xamarin forms project from past 6 months. Till now the development went well and after my windows 10 updated yesterday, My xamarin forms android is not getting build successfully. Its throwing error as "failed to open APK: Iteration ended."

Below are the two lines from output window

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(155,3): warning APT2258: W/ziparchive(18668): Zip: Entry at offset zero has invalid LFH signature 929c1a24
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(155,3): error APT2096: failed to open APK: Iteration ended.

Please help in resolving this asap.


PostAsync has occurred “the request timed out” on iOS Xamarin Forms

$
0
0

I use xamarin forms to create an mobile app for Android and iOS. I need to make Http Request, so I use HttpClient.

Here is a simple code of request :

var client = new HttpClient();
try
{
   string requestUrl = URL_DATABASE + "xxx";

   var content = new StringContent("{\"param\":\"" + param+ "\"}", Encoding.UTF8, "application/json");
   var response = await client.PostAsync(requestUrl, content);

   if (response.StatusCode == HttpStatusCode.OK)
   {
      var result = await response.Content.ReadAsStringAsync();
      return result;
   }

   return "{\"status\":-1}";
}

catch (Exception ex) // Error catched : "the request timed out"
{
   return "{\"status\":-1}";
}

I used Postman to check result of my request and work's well, I got good response without timeout.
I noticed that error occurs sometimes but can last an hour.

Thank you in advance for your help

CollectionView bug

$
0
0

Hi guys! Im using Xamarin.Forms 4.7 in my project and have issue with CollectionView.
This bug appears only on iOS and is displayed in approximately one build out of 10. I guess that bottom tabbed page causes this issue. Is there any ways to fix this?

iOS App crashing when binding to Text & IsVisible

$
0
0

I'm having issues with binding in iOS. We have numerous forms in our app and they're broadly set out as per the example with an Entry and an associated label for validation feedback - we're using FluentValidation for this. The label is hidden unless there are errors to show, this is so they take up no space on the interace when not required.

<Entry x:Name="UsernameEntry" 
    Placeholder="{Binding UILabelLoginName}"
    IsTextPredictionEnabled="False"
    PlaceholderColor="#333333"
    TextColor="#000000" 
    ReturnType="Done"
        Text="{Binding LoginName.Value}"
        InputTransparent="False">
    <Entry.Behaviors>
        <behaviors:EventToCommandBehavior
            Command="{Binding ClearValidationCommand}"
            CommandParameter="LoginName"
            EventName="Focused" />
    </Entry.Behaviors>
</Entry>

<Label
    IsVisible="{Binding LoginName.IsValid, Converter={StaticResource InverseBoolean}}"
    Style="{StaticResource ErrorLabelStyle}"
        Text="{Binding LoginName.FirstError}" />

This works lovely in Android, in iOS though the binding to IsVisible crashes the app. If we set IsVisible to true as opposed to binding it and set a fixed HeightRequest then it works fine but I don't want empty labels taking up space within the forms.

Android - On Load

Android - On Error

iOS - On Load (IsVisible set to Binding)

iOS - On Error (IsVisible set to Binding)

  • Crash

iOS - On Load (IsVisible set to True)

iOS - On Error (IsVisible set to True)

The exception at the time of the crash is,

Object reference not set to an instance of an object

at Xamarin.Forms.Platform.iOS.VisualElementTracker.UpdateClip () [0x00072] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:413
at Xamarin.Forms.Platform.iOS.VisualElementTracker.UpdateNativeControl () [0x0006c] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:386
at Xamarin.Forms.Platform.iOS.VisualElementTracker.HandlePropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x00064] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementTracker.cs:97
at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:229
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:353
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:461
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:334
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindablePropertyKey propertyKey, System.Object value) [0x0000e] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:318
at Xamarin.Forms.VisualElement.set_Height (System.Double value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:324
at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x0001a] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1081
at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:316
at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:708
at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:178
at Xamarin.Forms.TemplatedView.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\TemplatedView.cs:29
at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:812
at Xamarin.Forms.VisualElement.SetSize (System.Double width, System.Double height) [0x00021] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1083
at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x0005d] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:316
at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:708
at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.View child, Xamarin.Forms.Rectangle region, Xamarin.Forms.SizeRequest childSizeRequest) [0x00225] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:319
at Xamarin.Forms.StackLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00081] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:65
at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:812
at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0005c] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/Foundation/NSAction.cs:152
--- End of stack trace from previous location where exception was thrown ---

at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:65
at xxxx.iOS.Application.Main (System.String[] args) [0x00002] in C:\xxxx\xxxx.iOS\Main.cs:19

Any guidance would be very much appreciated!

Thanks

Xam.Plugin.Media Saving photo in both internal storage and SD card on Android

$
0
0

I use Xam.Plugin.Media Camera option. My app takes photo and uploads this photo to remote server. I want the user to choose whether can save the picture or not save on phone while they use Xam.Plugin.Media Camera option. So I did a basic ui for this. After the user's choice, I set SaveToAlbum (true or false) It works on iOS good. But on android it doesn't work on SD card.

After taking photo using " await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { } ) ", the following cases are belowing:

  • If "SaveToAlbum = true" and phone camera setting is SD card, Xam.Plugin.Media is save photo twice, one to internal storage and one to SD card. (it should save one photo just internal storage)
  • If "SaveToAlbum = true" and phone camera setting is internal storage, Xam.Plugin.Media is save photo twice, just internal storage. (it should save one photo just internal storage)
  • If "SaveToAlbum = false" and phone camera setting is SD card, Xam.Plugin.Media is save photo once, just SD card. (it should never save)
  • If "SaveToAlbum = false" and phone camera setting is internal storage, Xam.Plugin.Media is save photo once, just internal. (it should never save)

How can i fix this? Thank you.

On Platform values for font ionicons.woff

$
0
0

Hi

I am using custom font ionicons.woff and have used below;

    <ResourceDictionary>
        <OnPlatform x:TypeArguments="x:String" x:Key="ionicons">
            <On Platform="Android"
              Value="ionicons.woff#Regular" />
            <On Platform="iOS"
              Value="ioniconsr" />
        </OnPlatform>
    </ResourceDictionary>

However this is not working. What are the correct 'On Platform' values for font ionicons.woff and in general what is the method to get these values for a given font.

Thanks

Regards

Where is $(MSBuildExtensionsPath) located?

$
0
0

When creating a iOS Library porject and opening the csproj file I see <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" /> in the bottom. What is $(MSBuildExtensionsPath)and what is location of it?

Printerest like CollectionView renderer for iOS in Xamarin.Forms?

$
0
0

After some research I could find the custom renderer for CollectionView in Android and it works great, but I couldn't find the equalant for iOS. Please help me create it for iOS. Thanks

Custom CollectionView for android:

[assembly: ExportRenderer(typeof(CollectionView), typeof(CustomCollectionViewRenderer))]
namespace App.Droid
{
    public class CustomCollectionViewRenderer : CollectionViewRenderer
    {
        public CustomCollectionViewRenderer(Context context) : base(context)
        {
        }

        protected override void OnElementChanged(ElementChangedEventArgs<ItemsView> elementChangedEvent)
        {
            base.OnElementChanged(elementChangedEvent);

            if (elementChangedEvent.NewElement != null)
            {
                StaggeredGridLayoutManager manager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.Vertical);
                SetLayoutManager(manager);
            }
        }
    }
}

Custom CollectionView for iOS: ??


output console data to ui in xamarin.forms

$
0
0

I'd like to be able to send the Application Output / debug info to an entry box (or whatever works).

I tried using an Editor with and rerouting the console.out to it, but there seem to be major roadblocks with vague documentation. How can I catch this data and send it to my ui?

Thanks for reading :#

Content of a frame that is the View of a ViewCell appear on top of other rows in the list - iOS only

Get number from Incoming call and then launch my app

$
0
0

Hi Geeks,

I have a requirement where I need to work in the following scenario.

When any user gets a call, identify the number, and launch my app in the background and insert a record in some table.

I searched through different forums and found BroadcastReceiver is the one by which I can get the incoming number.

However, I tried to implement this, but no success.

[BroadcastReceiver(Enabled =true)]
[IntentFilter(new[] { "com.App.CALLER_RECEIVER" })]
public class IncomingCallReader : BroadcastReceiver
{
    public override void OnReceive(Context context, Intent intent)
    {
        switch (intent.Action)
        {
            case Intent.ActionNewOutgoingCall:
                Globals.ContactNumber = intent.GetStringExtra(Intent.ExtraPhoneNumber);
                var outboundPhoneNumber = intent.GetStringExtra(Intent.ExtraPhoneNumber);
                Toast.MakeText(context, $"Started: Outgoing Call to {outboundPhoneNumber}", ToastLength.Long).Show();
                break;
             case TelephonyManager.ActionPhoneStateChanged:
                var state = intent.GetStringExtra(TelephonyManager.ExtraState);
                if (state == TelephonyManager.ExtraStateIdle)
                    Toast.MakeText(context, "Phone Idle (call ended)", ToastLength.Long).Show();
                else if (state == TelephonyManager.ExtraStateOffhook)
                    Toast.MakeText(context, "Phone Off Hook", ToastLength.Long).Show();
                else if (state == TelephonyManager.ExtraStateRinging)
                    Toast.MakeText(context, "Phone Ringing", ToastLength.Long).Show();
                else if (state == TelephonyManager.ExtraIncomingNumber)
                {
                    var incomingPhoneNumber = intent.GetStringExtra(TelephonyManager.ExtraIncomingNumber);
                    Toast.MakeText(context, $"Incoming Number: {incomingPhoneNumber}", ToastLength.Long).Show();
                }
                break;
            default:
                break;
        }
    }


   protected override void OnCreate(Bundle savedInstanceState)
    {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;
        base.OnCreate(savedInstanceState);
        Xam.Essentials.Platform.Init(this, savedInstanceState);
        global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
        RegisterReceiver(new IncomingCallReader(), new IntentFilter("com.uniconta.mobile_new.app"));
        LoadApplication(new App());
    }

Second Approach:

 public interface ICallReceiver
   {
    void OnReceive();
   }

public class IncomingCallReceiver: ICallReceiver
{
    public void OnReceive()
    {
        Intent intent = new Intent("com.uniconta.CALLER_RECEIVER");
        var incomingPhoneNumber = intent.GetStringExtra(TelephonyManager.ExtraIncomingNumber);
        Globals.ContactNumber = incomingPhoneNumber;
        Forms.Context.SendBroadcast(intent);
    }
} 

DependencyService.Get().OnReceive();

I want this method to be called whenever the user gets a call.

1st question - Is it possible to get the incoming call number in Xamarin forms?
2nd Question - is it possible to launch an app in the background when someone gets a call and app can do things in the background?

Thanks
Anand

Export a scroll page to PDF

$
0
0

I need to convert my scroll page into the pdf in Xamarin forms. My Scroll page has contained so many elements and i need to export everything to the Pdf.

can anyone please help ?

Xamarin Forms, cannot generate IPA file for IOS project

$
0
0

Hello,

I have a Xamarin.Forms app that we run on Android, IOS and Windows. Android and Windows work fine and we have them deployed. IOS works fine in the Simulator, and I can install to an iPad via a USB cable. But, I have been unable to generate an IPA file for wider distribution.

When running the Release build (Build IPA is checked), all seems to go well but no IPA file is generated.

The only thing that looks awry is this warning message: "There is no available connection to the Mac, hence the task Xamarin.Messaging.Tasks.CopyFileFromMac will not be executed".

Our MacInCloud server is paired for the build session, so should be "available". But I assume this is why we are not getting the IPA file? Does that message imply that I could/should be able to find the file out on the MacInCloud server somewhere? I looked around, but could not see one.

VS.2019 is latest build, and NuGet Xamarin packages are also latest.

Can anyone give me some guidance on how to get our IPA generated?

Thanks for any help.

Bryan Hunt

Xamarin Forms: How to highlight text and pause/play audio of text to speech?

$
0
0

I am using the xamarin essentials package for text to speech feature. When speech the text I need to highlight the corresponding text. Also, I need an option to pause/play the speech. Please see this video.

Screenshot:

enter image description here

How can I achieve highlight text feature and pause/play audio as the video?

How to consume Jar file in Xamarin forms UWP project?

$
0
0

Hi..
I am having a JAR file containing html images to view in WebView.
How to use that JAR file to view in my Xamarin forms UWP Project.


How to Apply Style to particular Class name Div (HTML text) in Xamarin forms

$
0
0

Hi,

I am trying to load HTML content in a Label. I am getting Data like

April 1:

Due to revised NSPS emission limits for new room heaters, several wood stoves currently stocked in the RSCs will not be EPA compliant in 2020 and need to be sold or destroyed by May 15. AS OF MAY 15, YOU CANNOT SELL THESE UNITS TO CONSUMERS.

Vendors will not be taking back inventory of these units, so you are advised to sell through any stock on hand prior to the May 15, 2020 deadline. All impacted units on-hand as of May 15 are deemed unsellable and will need to be salvaged.

Please see the list of impacted SKUs and previous notices about this upcoming stop sale below for additional details.

 

Feb. 26, 2020:

We have added a $100 Instant Savings ONLINE to two U.S. Stove Wood Burning Stoves to help sell-through current inventory. These stoves are Ace Nos. 4639712 (54000 BTU 900 sq. ft. Wood Stove – 1269E) and 4639720 (94000 BTU 1600 sq. ft. Wood Stove – 2469E). We will honor the $100 for any stores who price matches the online price. Please contact the Ace Retailer Care Center to complete the instant savings reimbursement process.

 

Dec. 13, 2019:

In 2020, the NSPS emission limit for new room heaters will be lowered to 2.0 grams per hour if tested with crib wood*, or 2.5 grams per hour if tested with cord wood*.

All new wood heating appliances subject to the New Source Performance Standard for New Residential Wood Heaters under the Clean Air Act offered for sale in the United States are required to meet these emission limits.

As a result, several wood stoves currently stocked in the RSCs will not be EPA compliant in 2020 and need to be sold or destroyed by May 15. AS OF MAY 15, YOU CANNOT SELL THESE UNITS TO CONSUMERS. We are working with all vendors on transition plans for all existing stoves impacted by this regulation. We will continue to post subsequent communication in addition to specific action plans for all impacted stoves. We are closely monitoring inventory in the RSCs as well to ensure we're able to supply the demand this season, but not put anyone at risk of overstock in the Spring.

Attached is the list of the impacted Pellet and Wood Burning Stoves that will need to be sold before the May 15 deadline. Setup of replacement SKUs are in process and will be communicated once available on ACENET.

Submitted by: Daniel Kosinski – Merchandising

I have a div with class name "MobileBody". I want to apply style to it.
I tried the below one but it is working for only IOS, for Android All style tags are displaying ...
if (DeviceInfo.Platform.ToString() == "iOS")
{
ParagraphDesc = ".mobileBody{font-family:Roboto Slab; font-size:14px}" + responseData.BodyContent;
}

Can any one help on this

From Listview to Slider showing details

$
0
0

Have a Listview and with SelectedItemChangedEvent the details are showing on other page

Works fine.

But i found a Slider and is it possible to show the details in the Slider on the same page as the Listview and not on the other page ?

Fill the Listview from a Firebase database.

The Slider i made

https://xamaringuyshow.com/2020/06/21/xamarin-forms-bottom-slider/?utm_campaign=Weekly%2BXamarin&utm_medium=email&utm_source=Weekly_Xamarin_265 

Go to other page and show the details

async  void lstBal_ItemSelected(System.Object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
        {

                if (e.SelectedItem != null)
                {
                    await Navigation.PushAsync(new Waar
                    {
                        BindingContext = e.SelectedItem as Person
                    });
                lstBal.SelectedItem = null;
            }

        }

Building app from scratch - help

$
0
0

Hi,

I am looking to build a cross platform native feel wellness app and take it through every stage of the development process and maintain it long term. As I wish to do so at as little as possible a cost I am considering doing it all by myself via Xamarin coding learned from scratch.

My question from a beginners perpective, with no experience in coding or app creation, is: is this possible/realistic, and what would be the time resource required to do so on my own? I wish to ask experienced personel in the field of app creation their opinion to give me an idea if this is possible before I spend so many hours doing so only to find out the hard way its not. Any help greatly appreciated, thanks in advance!

Best regards,
Brian.

error MT2091

$
0
0

I am getting this error when building for iOS Release with Linker set to all or sdk framework.
error MT2091: Inliner failed processingSystem.Void MacAttribute::.ctor(System.Byte,System.Byte)``

What does that mean? I cannot find much on that error.

Is it correct to use Xamarin.Forms namespace in a ViewModel

$
0
0

I am a newbie in Xamarin.Forms and the architect in our team mentioned, if we wanted a clean architecture, we must avoid using Xamarin.Forms in ViewModel as it references Views directly so it actually doesn't decouple.

But in the most of the tutorials, guides I don't see this being followed.

Can anyone suggest what's the correct guideline, and how does it really support this decoupling? Does everyone follow the same?
Also, when I try to use buttonclick event via a Command class in the ViewModel, I can't use it without using Xamarin.Forms namespace.

How can I achieve pure decoupling without using the Command class?

Viewing all 89864 articles
Browse latest View live


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