Hello,
How to solve this problem of data output from the Android space class to the general classes of the project?
Do you want to transfer data from Xamarin.Android project to Share project?
If so, you can use MessageCenter to achieve it. Send a message from the Xamarin.Android project which will then be received by the Share project.
===========
Update=============
If you want to transfer data from DataSource.cs
to MainPage.xaml.cs
For example, I transfer result
data from Accelerometer_ReadingChanged
method of DataSource.cs
like following code.
void Accelerometer_ReadingChanged(object sender, AccelerometerChangedEventArgs e)
{
var data = e.Reading;
result = counter / 2;
//add transfer code here
MessagingCenter.Send<Object, string>(this, "TestMessage", result.ToString());
}
Then, you can get result in MainPage.xaml.cs , for testing, I set the text for Rakaat_1.Text
public MainPage()
{
InitializeComponent();
MessagingCenter.Subscribe<Object, string>(this, "TestMessage", (sender, arg) =>
{
string message = arg;
Rakaat_1.Text = message;
});
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.