xamarin update label and progress bars been killed by change to a different activity (need a fix)
min £36 GBP / hour
Concluído
Publicado há quase 4 anos
min £36 GBP / hour
We have a very simple app which reads data over a Bluetooth connection and updates a text string on a page. All the updates work as normal via the timer, but when we switch to a different page in the app and return to the home page, the updates stop working. We can set a break point on the text string update and we can see the new value but it does not update.
Why when we change to a different page and returns does it's stops the updates? It's a simple label and it's been updated in the UI?
I would like to understand how to fix this problem
using System;
using [login to view URL];
using [login to view URL];
using [login to view URL];
using [login to view URL];
using [login to view URL];
using [login to view URL];
using [login to view URL];
using [login to view URL];
using [login to view URL];
using [login to view URL];
using [login to view URL];
namespace Custom_TestAppHarness
{
[XamlCompilation([login to view URL])]
public partial class Homepage : ContentPage, INotifyPropertyChanged
{
public Homepage()
{
InitializeComponent();
// Start timer to update all the information on the home activity
if (App._timeerhasstarted == false)
{
App._timeerhasstarted = true;
[login to view URL]([login to view URL](5), () =>
{
[login to view URL](() =>
{
testcall();
});
return true; //use this to run continuously
});
}
}
void testcall()
{
[login to view URL](async () =>
{
[login to view URL] = [login to view URL]();
[login to view URL] = App._vehiclefuellevel;
[login to view URL] = App._vehiclebatterylevel;
});
}
protected override void OnAppearing()
{
[login to view URL]();
[login to view URL] = [login to view URL]();
}
}
}
XML code for the label
<Label
x:Name = "BTTextStatus"
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="6"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"
TextColor="#cccccc"
FontSize="Medium"/>
Hi,
I can solve your problem, it's kind of you update your label on main thread and when you navigate to another page the new page push into the stack and so it obviously not update the label.
I have the solution.
Let's introduce myself -
I have 4+ years of experience in Xamarin and developed 10+ app.
I checked your code and now I am trying to solve your problem.
So if you are interested you can contact me.
Thanks
£36 GBP em 20 dias
5,0 (7 avaliações)
4,3
4,3
3 freelancers estão ofertando em média £36 GBP/hora for esse trabalho
I have 7+ years of experience working with Xamarin platform and delevered around 20+ CrossPlatform Mobile apps so far.
I can look into this issue and fix it. It looks like a Timer issue.
I would say it is not a good practice to use a Timer to perform such type of task. There are better alternatives to perform such implementation which I can apply after looking into your code and your implementation in App.xaml.cs.
Looking forward to hear from you.
Thanks.