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

Android and iOS scale totally different. Do I need styling?

$
0
0

I've created an App I call eTabber and it show guitar tabs in Android, iOS en UWP. I currently working on the iOS version and it seems to scale totally different from the Android version. That is not what I expected at all. Here are two samples. It is a complex application using a ChordPro parser that parses a text file containing ChordPro text. It then passes control to a TabContainer class that evaluates the ChordPro tree and creates a Xamarin.Forms control with content coming from code. The Andoid version has a bit too much spacing but further look allright. The iOS version doesn't look good at all.

To make a bit more clear what is what. The colored images show a ColumnLayout (which is one of my own layout classes) in Green and a FlexLayout in Yellow. The ColumnLayout is working fine b.t.w.

Here's the Android layout:

and here's the iOS layout:

Here's the code for the word with or without a Chord (the black background blocks).

        private void HandleBlocks(ILine line, Layout<View> layout, IEnumerable<Block> blocks, bool inline = false)
        {
            if (!blocks.Any())
            {
                var label = CreateLabel(line, string.Empty, UseColor);
                layout.Children.Add(label);
            }
            else
            {
                foreach (var block in blocks)
                {
                    switch (block.GetType().Name)
                    {
                        case nameof(Chord):
                            HandleChord(line, layout, (Chord)block);
                            break;

                        case nameof(Word):
                            HandleWord(line, layout, (Word)block, inline);
                            break;

                        default:
                            break;
                    }
                }
            }
        }

        private void AddSpace(ILine line, Layout<View> layout)
        {
            Label label = CreateLabel(line, string.Empty, UseColor);
            label.Padding = new Thickness(0, 0, 2, 0);
            layout.Children.Add(label);
        }

        private void HandleWord(ILine line, Layout<View> layout, Word word, bool inline)
        {
            foreach (var syllabe in word.Syllables)
            {
                var chordLayout = new StackLayout
                {
                    Orientation = StackOrientation.Vertical,
                    Spacing = 0,
                    StyleClass = new List<string> { "WordContainer" }
                };

                if (syllabe.Chord != null)
                {
                    HandleChord(line, chordLayout, syllabe.Chord);
                }
                else
                {
                    if (!inline)
                    {
                        var emptyLabel = CreateLabel(line, string.Empty, UseColor);
                        chordLayout.Children.Add(emptyLabel);
                    }
                }

                var label = CreateLabel(line, syllabe.Text ?? string.Empty, UseColor);
                chordLayout.Children.Add(label);

                layout.Children.Add(chordLayout);
            }

            AddSpace(line, layout);
        }

        private void HandleChord(ILine line, Layout<View> layout, Chord chord)
        {
            var text = chord.Text == null ? string.Empty : $" {chord.Text}";
            var label = CreateLabel(line, text, bold: true, textColor: ChordColor);
            layout.Children.Add(label);
        }

Android Q API 29 - accessibility service audio call recording getting silence

$
0
0

I have a Xamarin Forms app that starts an accessibility service and gets the audio manager from the the GetSystemService() method in the service's OnServiceConnected() method( Fired when the user grants access to the service).

In the OnAccessibilityEvent() i listen for the Audiomanager state to change to InCall Status and use this event to start recording audio using the MediaRecorder.

The issue is that the recorder only records silence and when the call is ended I only get the last few seconds of audio, after the call is stopped. According to the Andriod Q Docs on audio sharing the Media Recorder should be able to record if it is in a accessibility service.

I have also tried the getting the telephony manager and Firing the recording in the callstate changes but with the same results.

My code below:

service start:
var intenttoaccess = new Intent(this, typeof(AccessService)); StartService(intenttoaccess);

service Decoration:
[Service(Label = "MyApp", Permission = Manifest.Permission.BindAccessibilityService)]
[IntentFilter(new[] { "android.accessibilityservice.AccessibilityService" })]
public class AccessService : AccessibilityService

On service Connected

protected override void OnServiceConnected()
{ var accessibilityServiceInfo = new AccessibilityServiceInfo(); accessibilityServiceInfo.Flags = AccessibilityServiceFlags.Default;//enum 1 accessibilityServiceInfo.EventTypes = EventTypes.AllMask; accessibilityServiceInfo.FeedbackType = Android.AccessibilityServices.FeedbackFlags.Generic; SetServiceInfo(accessibilityServiceInfo); AudManager = (AudioManager)GetSystemService(Context.AudioService); }`

On Event:

public override void OnAccessibilityEvent(AccessibilityEvent e)
{
if (AudManager.Mode == Mode.InCall)
{
if (Started == false)
{
StartRecording();
}
}
if (AudManager.Mode == Mode.Normal)
{
if (Started)
{
StopRecording();
}
}
}

Start recording

string Filename = "TestFile.3gp";
Java.IO.File Loc = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryMusic);
SoundPath = Path.Combine(Loc.AbsolutePath, Filename);
_recorder = new MediaRecorder(); _recorder.SetAudioSource(AudioSource.VoiceCommunication); _recorder.SetOutputFormat(OutputFormat.ThreeGpp); _recorder.SetAudioEncoder(AudioEncoder.AmrNb); _recorder.SetOutputFile(SoundPath); try { _recorder.Prepare(); _recorder.Start(); } catch (Java.Lang.IllegalStateException ise) { throw; } catch (IOException ioe) { throw; }`

Permissions:

`<uses-permission android:name="android.permission.RECORD_AUDIO" />`
`<uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />`

I seems to me that my accessibility service does not have the required priority to access the audio output during the call. If so how do I elevate it, or start the service in a way that grants that level.

Any assistance will be greatly appreciated.

Problem with IOS deployment

$
0
0

Hi,
I am trying to deploy an IOS-App to the Apple store. without success.

My first try was to deploy it from my windows PC, paired with a MAC. This failed with an error when VS wants to upload my package to the store:"unable to create an authentication sesson."

My next try was to deploy this package directly from the MAC, same error message.

Apple says the do not see an attempt for an upload and suggested to use Xcode, or Transporter-App.

I have tried the transprote-App, but this fails with this error:

ERROR ITMS-90122: "Invalid Executable Size. The size of your app's executable file 'VisitorCounter.iOS.app/VisitorCounter.iOS' is 66109440 bytes for architecture 'arm64', which exceeds the maximum allowed size of 60 MB."

How can I deploy my App ??????

Thanks in advance,

Martin Stein

Can we bind two command for same control.

$
0
0

Need two command for entry TextChanged & UnFocused in listview using MVVM

How generate a layout with a Button ?

$
0
0
Hello, I'm looking for a way to generate on a page (let's call it ArticlePage) a stacklayout that would have entries thanks to a button (let's call it Add), and when generating it, we stay on the ArticlePage, the stack is added with the Add button underneath and so on... I don't really see how I can make something clean, an idea ? Thank you!

Cheap android devices to test with

$
0
0
So to test in app purchases I need a real device from what I read. What are good cheaper devices to test with?

Implenting Google Ad Mobs in Xamarin.Android?

$
0
0

Hey,
does anybody know here a way to add Google AdMobs to a Xamarin.Android App with the GooglePlaySevrices.Ads.Lite SDK? I found this tutorial here, but unfortunately, some of the code blocks are empty! 🤔

admob pre-launch errors

$
0
0

App works in debug mode on emulator. However, I get the following on pre-launch. cannot figure out how to resolve.

Anyone run into this

Process: com.dnktechnologies.SWLog, PID: 18323\
java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAdsInitProvider" on path: DexPathList[[zip file "/data/app/com.dnktechnologies.SWLog-7oXNguA79p9Hrsr-w1PFSQ==/base.apk", zip file "/data/app/com.dnktechnologies.SWLog-7oXNguA79p9Hrsr-w1PFSQ==/split_config.arm64_v8a.apk", zip file "/data/app/com.dnktechnologies.SWLog-7oXNguA79p9Hrsr-w1PFSQ==/split_config.xxhdpi.apk"],nativeLibraryDirectories=[/data/app/com.dnktechnologies.SWLog-7oXNguA79p9Hrsr-w1PFSQ==/lib/arm64, /data/app/com.dnktechnologies.SWLog-7oXNguA79p9Hrsr-w1PFSQ==/base.apk!/lib/arm64-v8a, /data/app/com.dnktechnologies.SWLog-7oXNguA79p9Hrsr-w1PFSQ==/split_config.arm64_v8a.apk!/lib/arm64-v8a, /data/app/com.dnktechnologies.SWLog-7oXNguA79p9Hrsr-w1PFSQ==/split_config.xxhdpi.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]\
at android.app.ActivityThread.installProvider(ActivityThread.java:6988)\
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)\
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)\
at android.app.ActivityThread.access$1300(ActivityThread.java:219)\
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)\
at android.os.Handler.dispatchMessage(Handler.java:107)\
at android.os.Looper.loop(Looper.java:214)\
at android.app.ActivityThread.main(ActivityThread.java:7356)\
at java.lang.reflect.Method.invoke(Native Method)\
at


Refreshing items in CarouselView does not recreate custom controls

$
0
0

I have a CarouselView with ItemsSource bound to a collection of objects. Inside the view I have a DataTemplate with some layouts and eventually a custom control that has properties bound to properties of the objects in the collection. When I refresh my view the items in the list are refreshed, but my custom control is not recreated for each item. Specifically, I'm trying this scenario:

  1. Start the app, which shows 2 items in the view.
  2. Perform an action that causes one of the items to be removed from the ItemsSource collection. This properly removes it from the view when I refresh.
  3. On a different page, alter some values in the removed item.
  4. Perform a different action that causes that removed item to be added back to the collection. This also properly shows it again when I refresh, but, the custom control does not reflect the altered values.

What I'm expecting is that when I refresh the view that my custom control will be recreated for each item in the refreshed list, but this is not what is happening. If I debug I can see that my custom control's constructor is only called the first time the view is created, but when I refresh it is not.

Why doesn't my custom control get recreated when the collection changes, or how can I make this happen? To clarify, when I refresh the collection I'm reloading data from the server and creating new instances of my model objects. So, the refreshed collection isn't a collection of the same objects, it's a collection of new objects.

Below is some relevant code. The controls:OfferControl is my custom control that is not getting recreated when I refresh.

<CarouselView
    Position="{Binding Position}"
    HeightRequest="100"
    HorizontalScrollBarVisibility="Never"
    ItemsSource="{Binding OffersWithOrder}"
    PeekAreaInsets="16,0"
    VerticalOptions="FillAndExpand">
    <CarouselView.ItemsLayout>
        <LinearItemsLayout
            ItemSpacing="10"
            Orientation="Horizontal"
            SnapPointsAlignment="Center"
            SnapPointsType="Mandatory" />
    </CarouselView.ItemsLayout>
    <CarouselView.ItemTemplate>
        <DataTemplate x:DataType="viewmodels:OfferWithOrder">
            <StackLayout
                Padding="0,8"
                Style="{DynamicResource StackVerticalNoPadding}">
                <Frame
                    BorderColor="{DynamicResource ColorPrimary}"
                    Style="{DynamicResource FrameCarouselPanel}">
                    <controls:OfferControl
                        Offer="{Binding Offer}"
                        Order="{Binding Order}" />
                </Frame>
            </StackLayout>
        </DataTemplate>
    </CarouselView.ItemTemplate>
</CarouselView>

TouchEffect is not raised when TapGestureRecognizer is enabled

$
0
0

Hi all,

I my "Custom" View I have the following TapGestureRecognizer:

            var tapGestureRecognizer = new TapGestureRecognizer();
            tapGestureRecognizer.Tapped += async (s, e) =>
            {
                await this.BlinkAnimation();
                Clicked?.Invoke(s, e);
            };
            GestureRecognizers.Add(tapGestureRecognizer);

But when I add this code View becomes untouchable !!
TouchEffect is used from https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/effects/touch-tracking

But when I comment out this code TouchEffect has been raised ...

But I need TapGestureRecognizer and TouchEffect to work simultaneously !!

Is there a way to do this ?

Scroll ScrollView programatically based on TouchEffect

$
0
0

I tries to programmatically scroll ScrollView based on TouchEffect, but when I do that it scrolls not properly, it scrolls instead of up it scrolls down and instead of down - up ...

Also from some point it stop scrolling ...

Here is code that I use to scroll programmatically:

            TouchEffect touchEffect = new TouchEffect();
            touchEffect.TouchAction += async (sender, args) =>
            {
                await Scroller.ScrollToAsync(args.Location.X, args.Location.Y, true);
            };
            Scroller.Effects.Add(touchEffect);

Is there a way to send data from View Model to code behind?

$
0
0

Is there a way to send data from View Model to code behind?

Third party package source in Visual Studio for Mac

$
0
0

We host our own nuget package source for some internal nuget packages

This works fine from Visual Studio for Windows. However on Visual Studio for Mac the build breaks with errors:

NuGet Config files used:
/Users/unifydev/.config/NuGet/NuGet.Config

Feeds used:
https://api.nuget.org/v3/index.json

Unable to find package Tait.MvvmCross.Plugins.UserInteraction. No packages exist with this id in source(s): nuget.org
Unable to find package Tait.MvvmCross.Plugins.UserInteraction. No packages exist with this id in source(s): nuget.org
Unable to find package CoAPNetMobile. No packages exist with this id in source(s): nuget.org
Unable to find package Tait.MvvmCross.Plugins.UserInteraction. No packages exist with this id in source(s): nuget.org
Unable to find package Tait.MvvmCross.Plugins.UserInteraction. No packages exist with this id in source(s): nuget.org
Unable to find package Tait.MvvmCross.Plugins.UserInteraction. No packages exist with this id in source(s): nuget.org
Restore failed.

It appears to be using the NuGet.Config from my home folder instead of the one from my source. Which is in a folder called .nuget in the same folder as my solution.

The nuget manager in Visual Studio for Mac can see the package source and browse it no problem. But the build isn't using it. Is there a way to fix this or do I have to configure it in my home directly (affecting all projects instead of just the one that needs it)

Two listviews on one page

$
0
0

Hi All,

I've seen several topics on this, but none of them worked for me (or I cannot make it work for me): how to add two listviews with separate data on one page?

In my case, I want two listviews under each other. I have one listview already inside a grid. The code for this listview is:

How can I add a second listview under this current listview?

March 30, 2017 - Indianapolis, IN - Indy.Code() - Beyond the Basics with Xamarin.Forms

$
0
0

Beyond the Basics with Xamarin.Forms
At the heart of a great Xamarin.Forms mobile app is the ability to customize the user experience and shorten development time with reusable components. In this session, you will learn the skills to create high quality, robust, and beautiful apps all the while creating an arsenal of reusable components. You will learn how to extend Xamarin.Forms controls beyond their built-in abilities; how to style user interfaces, display dynamic data within lists and build complex layouts with grids; you’ll even learn how to integrate native controls right into the shared code layer. When you’re finished with this session, you’ll have the knowledge of Xamarin.Forms necessary to create fantastic apps in the real world.

Speaker: Matt Soucoup
Matthew Soucoup is a Microsoft and Xamarin MVP, a Pluralsight author, a Telerik Dev Expert, and a principal at Code Mill Technologies. Matt loves mobile development. For his job, he creates elegant cross-platform apps. For fun, Matt shares his passion and insight on mobile and cloud development by blogging, writing articles, and presenting at conferences such as Xamarin Evolve, CodeMash, That Conference, and Indy.Code(). When not behind a computer screen, Matt gardens hot peppers, rides bikes, and loves Wisconsin micro-brews and cheese. Follow Matt on Twitter at @codemillmatt and his blog at https://codemilltech.com.

Time: Thursday March 30, 2017
Place: Indy.Code() Conference - Indianapolis, IN
Sign Up: https://indycode.amegala.com/


25 June 2020, Xamarin Warsaw Mobile Developers #19 - ONLINE

$
0
0

I'm pleased to announce yet another Xamarin Warsaw Mobile Developers meetup!

Join us ONLINE: meetup.com/XamarinWarsawMobileDevelopers/events/270974482/ - sorry for providing link in such form, but I can't yet post direct links :(

🗓 Agenda

🚀 18:00 - 18:05 | Opening

1️⃣ 18:05 - 18:50 | Mobile Security recipes for Xamarin developers | Nico Milcoff
[EN 🇬🇧]

Mobile apps are the main source of security concerns in every software solution nowadays. But it doesn't have to be like that: In this session we will explore best practices, tips and tricks from OWASP MASVS that will take your app to a next level! Just remember: You don't need to be an expert to make an app secure.

Nico:
Nicolas is a mobile development expert. He works as CTO at Xablu and he is also a Microsoft MVP who actively contributes to / maintains open source projects like MvvmCross or BreachDetector. He loves to push forward the technologies he works with.

2️⃣ 18:50 - 19:00 | Break

3️⃣ 19:00 - 19:45 | TBA
[EN 🇬🇧]


🙋‍♀️ Call for Papers

Would you like to share some interesting topic on Xamarin Warsaw Mobile Developers? Great! Contact with me directly :smile: We are open for session propositions.

Xamarin Forms ListView strange overlap bug

$
0
0

Hello,

I've just come across a strange bug with the ListViews. Yesterday, I applied this fix https://devblogs.microsoft.com/xamarin/uiwebview-deprecation-xamarin-forms/ to send my app onto TestFlight which I am assuming might be the culprit as I do not recall seeing the bug before apply the above fix.

The bug looks as follows:

It looks as if there are multiple ListViews on top of one another but there are not.

Any help on this would be greatly appreciated.

low speed site

$
0
0

I have a problem with my site: www.irpolymer.com/
The GTMetrix shows that something is slowing it down. But no matter how hard I tried, I couldn't find it if I didn't have this problem on other sites

The server returned an invalid or unrecognized response

$
0
0

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.IOException: The server returned an invalid or unrecognized response.06-23 16:03:59.280 I/mono-stdout(15702): System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.IOException: The server returned an invalid or unrecognized response.

06-23 16:03:59.280 I/mono-stdout(15702): at System.Net.Http.HttpConnection.SendAsyncCore (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00cf5] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs:529 at System.Net.Http.HttpConnection.SendAsyncCore (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00cf5] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs:529
--- End of inner exception stack trace ---

PDFSharp.netstandard - XFont Operation is not supported on this platform.

$
0
0

Hi all,

I want to use PDFSharp.netstandard on Android and iOS to create and save a PDF-file (not viewing), but I get a error which I cannot place.

I have the following example code:

But now I get the following error when I want to create this PDF:

Does someone know how to use this on Android and iOS?

Viewing all 204402 articles
Browse latest View live


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