Writing sensor data to files in WearableListenerService - wear-os

I'm collecting data from sensor and write to files in WearableListenerService.
How do I start the service when the watch boots and keep it running all the time?
It seems that Android wear automatically start this service if there's correct configuration in manifest. If not, do I need to explicitly send an intent from MainActivity?

How do I start the service when the watch boots and keep it running all the time?
Follow the steps below and hopefully it starts your service from this document: Android Wear Quickstart
Building a Watch Face Service
To create an Android project for your watch face in Android Studio:
1.) Click File > New Project and follow the steps in the Create New
Project wizard until you reach the Target Android Devices page.
2.) Select
the Wear option, and in the Minimum SDK option list, select the latest
available (API Nougat) option. Click Next.
3.) Select Add No Activity and
click Next in the two following screens.
4.) Click Finish.
Android Studio
creates a project with a wear module. For more information, see
Creating a Project.

Related

How to get a Xamarin iOS notification service extension working?

I'm trying to add a notification service extension to my Xamarin iOS so that I can receive silent notifications. I'm using OneSignal and have followed their instructions and set up everything that I think is required:
App bundle id = com.abc.abcapp
Extension bundle ID = com.abc.abcapp.OneSignalNotificationServiceExtension
Added extension project reference to app
Enabled App Groups in app & extension and set to group.com.abc.abcapp.onesignal (also registered this in Apple developer portal)
Using Automatic Provisioning for both, which seems to have registered everything properly
It builds fine. I have Visual Studio 2022 deploy it to a physical iPhone plugged into my computer. It deploys fine. But notifications don't appear to go to the extension. They just go to the App, which limit the number of silent notifications I can send to a device to a few an hour.
Some possibly useful debugging?
Getting the phone's device log in Visual Studio is really hit or miss but at one point I did see this err:
Library Validation failed: Rejecting '/private/var/containers/Bundle/Application/11D98889-9C2C-4218-A2C8-227C93CBD579/Abc.app/PlugIns/OneSignalNotificationServiceExtension.appex/libOneSignalNotificationServiceExtension.dll.dylib' (Team ID: none, platform: no) for process 'OneSignalNotific(2868)' (Team ID: CJTV38PNRD, platform: no), reason: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
When I try to build this in MS App Center, it doesn't recognize that I have an extension and doesn't let me associate a second profile or cert. (which I think it's supposed to do?)
According to documentation You can’t modify silent notifications or those that only play a sound or badge the app’s icon.

How to add admob ads to Xamarin IOS

I am trying to add Admob Ads to Xamarin.IOS but i am unable to figure out way to achieve this goal.I have already searched internet but couldnt find the solution
Google Admob is available in Xamarin.iOS .
1.install the package Xamarin.Firebase.iOS.AdMob from nuget.
2.Registring with AdMob
So, the first thing that you will need to do is actually register for AdMob. This is the same thing that I did in Android, but I created an iOS project. This will give you two important pieces of information, your “Application Code” and your “Ad Unit Id”. We will use these later, but simply go to: https://apps.admob.com, register for a new app, link to an app in Firebase, and you will be off running.
3.Add GoogleService-Info.plist
When you create the new app in Admob/Firebase there will be a Google Service config plist file that gets downloaded. Add this to the root of your iOS project and make sure that the Build Action is set to BundleResource. This is super important!
4.Update AppDelegate
MobileAds.Configure("Your Publishing App Id");
You can ask for more details about Admob . And here is a sample that you can refer.

Appcelerator App Conversion iOS to Android.

One of our developer developed an app in appcelerator using alloy framework for iOS which works fine. Now we want to run the same app in Android, since the appcelerator is a cross platform tool, we wish to make the Android version of the App. I tried searching about it and explored the applcelerator ide for options but couldn't find it. Can some one please guide me into the right direction?
First of all have a look at this link : http://docs.appcelerator.com/platform/latest/#!/guide/Supporting_Multiple_Platforms_in_a_Single_Codebase this will guide you to update the application for multiple platforms.
Their are basically two different ways to port any application from android to iOS or vise-versa, but before that just let me clear one more thing to you about tiapp.xml.
In the tiapp.xml of your project you need to updated the Development Target by checking for which platform you are developing the application for (iPhone, iPad, android, Mobile Web).
Option 1 :
Cross Platform is build to make code re-usable (i.e. re-use same code for all the platforms), but we have exceptions with many things. Their are lot of components that work fine in iOS but when you use them in android then you will face errors. So in that case you just need to apply conditions for android and iOS like below :
if(OS_ANDROID)
// do something
else if(OS_IOS)
// do something
What you need to do is that you need run the application in android simulator and test the application for these changes and then apply the changes accordingly.
Basically a developer has to target the UI for both the platforms, as their will not be any logical differences between the two. Also their will be UI changes between the same components, like for example a picker in iOS will not look the same as it will when you look it in an android application.
Option 2 :
Now in the project you have assets folder with the platform that you have selected in the tiapp.xml (i.e. iPhone, android etc).
You can create similar structure in the style and view folder, create two folders iOS and android in both the directory (i.e. style and view).
First, move .tss of style folder (except app.tss and index.tss) in the iOS folder, then copy the files in the android folder also.
Repeat the similar process with the View folder also.
Now you have two different structures (i.e. view and styles) according to their platform. Now you can run the application in android simulators and resolve the error that you face.
Hope this small information helps the cause, you can also have look at the documentation of all the components from below link :
http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TableView

Xamarin.Forms application properties not saved between sessions with Android

In my cross-platform app I save application properties in the following way:
Application.Current.Properties["myValue"] = "Test";
await Application.Current.SavePropertiesAsync();
I then retrieve them later like this:
string myVal = Application.Current.Properties["myValue"];
This works perfectly when using the Android emulator. I can close the emulator down, and when I restart it again, my app data is preserved.
However, when I deploy this app to a physical Android device, data preservation works as expected until I close the app and open it again. At this point I retrieve an empty value. It's as though the data is only saved to memory (and not to file).
Furthermore, the iOS version of the exact same app works faultlessly. When I open the app up, all previous values have been saved and I can retrieve them.
What am I doing wrong on the Android version? Is there an Android setting, permission, or option which I need to enable to have the values saved between app sessions when actually deployed to a phone?
I had a similar problem where only the debug version saved Properties. I think we're still waiting for the bug fix, and this is the workaround on Xamarin Forms bugzilla.
In short: go to .Droid project settings -> Android Options -> Linker
and enter/add "System.Runtime.Serialization" to Skip linking assemblies.
Wow! After lots of research, I have getting solution for same issue in mine. Problem is that, when i store List or DataTable in Application.Current.Properties then all properties are removed after reopen app but if i store List or DataTable as serialize, it working fine.
In VS you need to enable the option:
Preserve application data/cache on device between deploys
You can find this at Tools > Options > Xamarin > Android Settings.
I don't know if this has stopped in the latest updates of Xamarin Forms, the data is available until the application is running similar to session but persistent storage does not work.
The best api I think available for this is Akavache https://github.com/akavache/Akavache.
You can read this blog https://codemilltech.com/akavache-is-aka-awesome/.
Update
There is a bug filed in bugzilla:
https://bugzilla.xamarin.com/show_bug.cgi?id=26444
I don't remember exactly which part of this solved the issue, but when I followed the instructions to prepare the Android application for release from start to finish, the issue went away. The problem occurred when debug builds were used on an Android device.
https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing_an_application/part_1_-_preparing_an_application_for_release/
The link details the suggested settings for the Android project when releasing to device. Following these instructions should solve the issue.

Can't open the wearable-preview-support.jar for Android Wear

I'm trying to run the wearable-preview-support.jar from terminal and I get the error
java -jar wearable-preview-support.jar
Failed to load Main-Class manifest attribute from
wearable-preview-support.jar
Also just trying to open the jar by double clicking gives the error:
The Java JAR file "wearable-preview-support.jar" could not be launched. Check the Console for possible error messages.
No error messages were displayed in Console.
Anyone else having this problem?
The JAR isn't a self contained executable, it is a library to build the wearable apps off of. See this page for more information about how to use it. You have to reference it as a library in your Android application in order to run it, and you will have to run it in the Android virtual machine.
Here are some steps to get Android Wear working in a virtual machine. Keep in mind it might be a little underwhelming using it with a mouse since it'll be less responsive than the actual device will be (hopefully).
The jar file should be included in your Android application, you do not run it directly.
The "Android Wear Preview app" is an application you download from the Google Play Store which runs on your real device. You can only download this application if google have enabled you do. For this to happen you need to sign up at the Google wear preview signup - once you have downloaded the application, you then grant it notification access.

Resources