My question is How should i collect and write those data (GPS) ? Can i just call them through some events in PCL ? Or do i need some services ? Or should i create that funcionality in .android project ?
There are several ways to get the sensors data, you could so this in your PCL
.
Method 1 :
When you catch bluetooth
events in your BroadcastReceiver
, you could get sensors data in the OnReceive
method.
Method 2 :
You could use DependencyService to get the device sensors data and then write it do sqlite
database. As the document said :
Xamarin.Forms allows developers to define behavior in platform-specific projects. DependencyService then finds the right platform implementation, allowing shared code to access the native functionality.
About DependencyService
usage you could read the document or refer to my answer.
Method 3 :
You could use DeviceMotionPlugin to get these sensors data. When you use this plugin, you can call CrossDeviceMotion.Current
from any project or PCL
to gain access to APIs.
Update :
You could do implement this function in your PCL
. When you use method 2
or method 3
, you could get the sensors data in PCL
and then you could store these into your sqlite. Still use native Android API to get sensors data in native Android, but you could use these data in PCL
.