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

Getting Mono.AndroidTools.RequiresUninstallException on Android

$
0
0

Today I started getting this deployment error on android:

Severity Code Description Project File Line Suppression State
Error ADB0030: Mono.AndroidTools.RequiresUninstallException: The installed package is incompatible. Please manually uninstall and try again.
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A_work\267\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 339
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.b__0(Task1 t) in E:\A\_work\267\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753 at System.Threading.Tasks.ContinuationTaskFromResultTask1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at AndroidDeviceExtensions.d__11.MoveNext() in E:\A_work\267\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:line 187
--- End of stack trace from previous location where exception was thrown ---
at AndroidDeviceExtensions.d__11.MoveNext() in E:\A_work\267\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:line 194
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at AndroidDeviceExtensions.d__11.MoveNext() in E:\A_work\267\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:line 203
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Xamarin.AndroidTools.AndroidDeploySession.d__112.MoveNext() in E:\A_work\267\s\External\androidtools\Xamarin.AndroidTools\Sessions\AndroidDeploySession.cs:line 414
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Xamarin.AndroidTools.AndroidDeploySession.d__106.MoveNext() in E:\A_work\267\s\External\androidtools\Xamarin.AndroidTools\Sessions\AndroidDeploySession.cs:line 217
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.AndroidTools.AndroidDeploySession.d__104.MoveNext() in E:\A_work\267\s\External\androidtools\Xamarin.AndroidTools\Sessions\AndroidDeploySession.cs:line 119 0

It only happens in Debug, but in Release i can deploy and run the app just fine.
Why is this happening?

This morning i installed the Android SDK 10.0 and I suspect it started after that, so now I uninstalled it, but I still can't deploy because of the same error.
Other apps from the same PC can be deployed just fine, so I don't get it...

I did check this out
https://docs.microsoft.com/en-us/xamarin/android/errors-and-warnings/adb0030

but I don't even have my app installed on the device...

Thanks


Advanced map pin customization

$
0
0

I need to create a custom pin that has BorderColor, FillColor and Text properties as shown:

can it be designed and shared via SkiaSharp, or I have to design it for each platform?

more detail on how it can be created is greatly appreciated!

SQLite Extensions - Relations to different Databases

$
0
0

Hello,

I am new to SQLite and at the moment I am settings up one database with multiple tables and their relations, which works quite well, for example:

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

public string Version { get; set; }

[ForeignKey(typeof(ClassB))]
public int ClassBID { get; set; }
[OneToOne]
public ClassB InstanceB{ get; set; }
 }

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

public string Name { get; set; }
  }

   SQLiteConnection db = new SQLiteConnection(dbPath);

   db.CreateTable<ClassA>();
   db.CreateTable<ClassB>();

   ClassA instanceA = new ClassA();
   db.Insert(instanceA);

   ClassB instanceB = new ClassB();
   db.Insert(instanceB);

   instanceA.InstanceB = instanceB;

   db.UpdateWithChildren(instanceA);

This works and all tables are in the same DB.

But what if I wanted to relate to an entry in another database. Assume that the ClassB table was in a different database than the ClassA table.
Could I wire all up in a similar way? I habe read about the ATTACH command, but does the SQLite Extensions Syntax support this?

UITest iOS DeviceAgentException Unable to end session A task was canceled

$
0
0

I am seeing a similar problem as posted in the now read only Test Cloud forum. Running UI Tests on physical iOS devices causes the following error when switching between tests:

SetUp : Xamarin.UITest.XDB.Exceptions.DeviceAgentException : Unable to end session: A task was canceled.
  ----> System.Threading.Tasks.TaskCanceledException : A task was canceled.

I can run iOS simulators no problem but a physical device causes this error when it ends the first test and then attempts to do the second test. Has anyone else run into this problem? I can run each test individually just not successively in a single run.

Xamarin.UITest: v2.2.6
Test Server version: 0.21.7

Subscribing and Unsubscribing from notificiationhub with tags in xamarin

$
0
0

I am currently developing an App in Xamarin.Forms that recieves multiple notifications from notificiationhub for Android and UWP.

each notification has a tag that correspondent to a production line ID. My backend API has a hangfirejob that checks for the new entries in the database.

Recieving notifications is fine,but the users for the app do not need to recieve ALL notificiations.
Instead they can select in the app from which production line they want to see production stops.

Is there a way that i can select which notifications i want to recieve from a switch in Xamarin.Forms with these switches?

I tried to Unregister and register new tags each time the user made his selection, but the documentation of FCM state that you rarely have to unregister notificationschannel from an app. which also did not work with this code...

 public void ReRegisterToNotificationsHub(string token)
        {
            hub = new NotificationHub(AppSettingValues.NotificationHubName, AppSettingValues.ListenConnectionString, this);
            hub.UnregisterAll(token);
            var tags = GetLineValueKeysFromAppSetting();
            var register = hub.Register(token, tags);
            var regID = register.RegistrationId;
        }

Is there any other way that i can choose that i can filter the notifications to those that only has selected a line.
Can i dynamically reset my tags in a way without registering back or something?

Thanks in advance.

How can I read a RFID card in my Xamarin.Forms Application?

$
0
0

Hi guys, how can I read a RFID card in my Xamarin.Form Application?
In the end, I want to read this card over an android tablet.
Thanks.

Shell TabBar as Child Item

$
0
0

I'm currently creating an app with a different kind of login flow. Normally after the login page is closed and the main app pages are shown the login page isn't needed anymore. But in this use-case it should be very easy to change the current user. Also the user should sign in everytime the app starts.

So I want the login page to be on the top of the pages hierarchy and all other pages to be below this, so I can use the back button to easily go back to the login page. My idea is something like this: After the login page I want to get a tabbed view that shows my pages 1 to 3 and at the top of the tabbed view the navigation bar should be shown with a back button with which I can navigate back to the login page. A flyout is neither necessary nor wanted.
This would result in a hierarchy similar to this:

  • LoginPage
    • TabBar/TabbedPage/whatever
      • Page 1
      • Page 2
      • Page 3

How do I have to specify this in the AppShell.xaml. I just can't get it to work no matter how I do it.

Text from toolbar still showing while the toolbar itself is gone

$
0
0

Hello,

Could anyone tell me how to rid of the Datetime text as shown here:

I remove the toolbar using: NavigationPage.SetHasNavigationBar(this, false);
But only the bar itself is removed, not the text.

How can I get rid of everything ?

Thanks


How to send notifications to particular users?

$
0
0

Hi, I am working on xamarin forms, Where the requirement is like I need to send notifications to specific users whenever a new record is inserted in the table and app maybe foreground or background notification must go, How to do this?

How to convert ImageSource to an array of bytes to store in sqlite.

$
0
0

Hi, I need to save images to sqlite database. I can't find a working example. How to Convert ImageSource to Bytes Array.

Visual studio downgrade

$
0
0

I have installed Visual studio 2017 15.9.17 version. Is it possible to downgrade this to 2017 lower version?

Is there anyway to automatically close a browser after a redirect to your application?

$
0
0

I have the following situation (for my xamarin forms ios/android app):

  • I open my app.
  • I launch the browser from it.
  • I do some stuff and I redirect to my application, but the brower is still open.

Is there any way to automatically close it after I redirect from it to my app?

Thanks!

Does the Xamarin.Forms "FontSizeConverter" Type convert the XAML string value into NamedSize?

$
0
0

I'm getting compiler errors with regards to the values that can work with a FontSize property when assigned from XAML. Will the Xamarin.Foms "FontSizeConverter" handle NamedSize enumeration values ...AND... double values when passed in from the XAML file?

On my machine it doesnt accept the NamedSize assignments.

EDIT (thank you for the ability, otherwise it just results in a reply to myself):

It seems that my XAML files do work properly even when using NamedSize values for the FontSize property. However, I didn't realize this sooner because the XAML throws up red squiggly lines complaining about it but...ONLY...on my custom defined types. Not other Xamarin form types like Labels and Entrys.

How can I fix this so there is no complaints about it on my custom types?

Binding Question

$
0
0

Hi,
I am new to xamarin forms and i am stuck in following situation.
What i am trying to do is to bind a label in xaml like

If Any_Case.CaseMessage.IsRead
lbltest.Text=True
Else
lbltest.Text=False

My CasesModel
public class Cases
{
.....
public int Id { get; set; }
public virtual IList (CaseMessage) Messages { get; set; }
}

public class CaseMessage
{
public int Id { get; set; }
public bool IsRead { get; set; }
}

My ViewModel
public class CasesViewModel : BaseViewModel,INotifyPropertyChanged
{
public ObservableCollection CasesCollection { get; private set; }

    public CasesViewModel()
    {
        CasesCollection = new ObservableCollection<Cases>();

        GetSearchResult("");

    }

    private async void GetSearchResult(string text)
    {
        ....
            FillObservable(tr);

        }
        catch (Exception ex)
        {
            // Possible that device doesn't support secure storage on device.
        }
    }

    private void FillObservable(List<Cases> tr)
    {
        CasesCollection.Clear();
        foreach (var _case in tr)
        {

           CasesCollection.Add(_case);

        }
    }


}

}

My XAML

<ListView x:Name="MessagesListView" 
                      HasUnevenRows="True"
                      ItemsSource="{Binding CasesCollection}"
                      SeparatorVisibility="Default"
                      SeparatorColor="Black">
<ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.View>
                            <!--<StackLayout Padding="30,0,0,0" BackgroundColor="#E6E6E6" >-->
                            <StackLayout Padding="30,0,0,0">
                                **<Label x:Name="lbltest" Text="{Binding HasUnreadMessages}" />**
                            </StackLayout>
                        </ViewCell.View>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>

Thank you for any help

getting jpg from users gallery

$
0
0

i need to get a photo from a users gallery and atm i do so like this

private async void addprofilepicture_Clicked(object sender, EventArgs e)
{

        Stream stream = await DependencyService.Get<IPhotoPickerService>().GetImageStreamAsync();

        if (stream != null)
        {
            ImageSource Image;
            byte[] b = ReadFully(stream);
            String s = Convert.ToBase64String(b);
            Image = Xamarin.Forms.ImageSource.FromStream(
            () => new MemoryStream(Convert.FromBase64String(s)));
            imagebutton.Source = Image;
            basse64.Text = (stream).ToString();    
            Postbase(b);

        }



    }
    public static byte[] ReadFully(Stream input)
    {
        byte[] buffer = new byte[16 * 1024];
        using (MemoryStream ms = new MemoryStream())
        {
            int read;
            while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
            {
                ms.Write(buffer, 0, read);
            }
            return ms.ToArray();
        }
    }
    public async void Postbase(byte[] bytearray) {


        base64s s = new base64s()
        {
            base64string = bytearray

        };
        string stringpayload =  JsonConvert.SerializeObject(s);

        await myAPI.PostProfilePhoto(s);



    }
  public  class base64s { 
      public byte[] base64string { get; set; }


    }

as you can see i get a byte[] and send it but it takes so long to send that that application will crash waiting and my backend will list a very long string to the console for minutes. obviously users shouldnt have to wait this long to send a picture. so how to a get a jpg or maybe even png to send from users gallery. all i find on microsoft sites is how to get it from drawable but direct me to right place if there is a tutorial on this.


Report switching my xamarin app is in background

$
0
0

i have created exams in my app and want to know
how can i detect my app is in background (or switched this exam page )and which app in came foreground(to avoid googling)

Checking if MediaPlayer is playing couses a short stop?

$
0
0

I have this code, that runs in the background and when I receive my part of a song, it is than being played. I than save it to a temp mp3 file, and than it is played, but between parts, there is a small stop. I use while, to check if a song is playing, so I can release the resources. How would I remove that stop. I am using Xamarin.Forms (that is why there are Java libraries).

This is my code:

while (true)
{
    try
    {
        byte[] myReadBuffer = new byte[10000];
        MediaPlayer player = new MediaPlayer();
       Java.IO.File temp = Java.IO.File.CreateTempFile("temp", "txt");
       Java.IO.FileOutputStream fos = new Java.IO.FileOutputStream(temp);
       Java.IO.FileInputStream fis = new Java.IO.FileInputStream(temp);
       temp.DeleteOnExit();
       mmInStream.Read(myReadBuffer, 0, myReadBuffer.Length);
       fos.Write(myReadBuffer, 0, myReadBuffer.Length);
       fos.Close();
       player.SetDataSource(fis.FD);
       player.Prepare();
       player.Start();
       while (true)
       {
          if (!player.IsPlaying)
          {
               player.Release();
               break;
           }
        }
   }
   catch (System.IO.IOException ex)
   {
       System.Diagnostics.Debug.WriteLine("Input stream was disconnected", ex);
   }

}

I did try Thread.Sleep(), but I think that is kinda not so efficient.

Add Resources to a Multi-Targeted Project/Nuget

List child element is not able to find by using the Appium tool

$
0
0

Hi Folks,

I have worked in the Appium testing tool (Version: 1.15.1), I am testing to Xamarin hybrid app (iOS and Android). I can select the view and also get xpath. But, In the list view, I am not able to select the child elements in the list view and also couldn’t find the xpath for child elements.

We have given automation id in source code. Even Appium inspector is not able to get elements. We used Xamarin.Form 4.3, 4.2, 3.5, and 3.0 versions.

        <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell AutomationId="MyViewCell" AutomationProperties.IsInAccessibleTree="True" >
                            <StackLayout Padding="10" AutomationProperties.IsInAccessibleTree="True" >
                                <Label x:Name="titleLbl" AutomationId="TitleLabel" Text="{Binding Text}" d:Text="{Binding .}" LineBreakMode="NoWrap" Style="{DynamicResource ListItemTextStyle}" FontSize="16" AutomationProperties.IsInAccessibleTree="True" />
                                <Label x:Name="desc" AutomationId="DescLabel" Text="{Binding Description}" d:Text="Item descripton" LineBreakMode="NoWrap" Style="{DynamicResource ListItemDetailTextStyle}" FontSize="13" AutomationProperties.IsInAccessibleTree="True" />
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>

Kindly give solutions for this problem.

Thanks.

Geolocation - How can I improve the retrieval of coordinates ?

$
0
0

How may I improve on this:

 private static Location loc = null;
 private async void BttLocation_Clicked(object sender, EventArgs e)
        {
            if (loc != null)
            {
                loc = await Geolocation.GetLastKnownLocationAsync();
            }
            else
            {
                var request = new GeolocationRequest(GeolocationAccuracy.Medium);
                loc = await Geolocation.GetLocationAsync(request);
            }

            Map.MoveToMapRegion(MapSpan.FromCenterAndRadius(
                    new Position(loc.Latitude, loc.Longitude), Distance.FromMiles(1)), true);
        }
Viewing all 77050 articles
Browse latest View live


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