Xamarin Forms Manage Alarm Clock - c#

Is it posible to manage the alarm clock from Android and iOS with the same Xamarin Forms code?
I have seen that its possible with nativ code.
thanks!

No.
Xamarin.Forms is essentially an absraction layer over native code.
You will be able to create a user interface that shared between each platform you target, but you will need to write your own abstraction of the native platform API(s) that you wish to consume to get the behavior that you desire. As stated above, you can utilise the Dependency Service to achieve this.

Related

Using Native Page in Xamarin Cross Platform Application

I have Xamarin Cross Platform Application in Visual Studio 2022. I have a Main Page where i want 2 buttons.
"Take me to Android Page" Button
"Take me to iOS Page" Button
I want to create a sample NATIVE page specifically in Android Project of this Cross Platform Application and one sample NATIVE page specifically in iOS Project within this Xamarin Cross Platform Application.
When I will click on "Take me to Android Page Button", it should take me to Natively designed Page of Android and when I will click on "Take me to iOS Page Button" then it should take me to Natively designed page in iOS Project.
I hope anyone can give me any reference or sample codes to achieve this goal.
Thank You
Xamarin.Forms is designed to prevent the need to design each page for both platforms by using XAML to define shared layouts rendered at runtime using native controls. If you can expand your question to include reasons why you need to define fully native page layouts for each platform, that will help better inform answerers.
If you need the ability to create custom controls for each platform, consider custom renderers which will allow you to define platform-specific behavior for individual views in your XAML pages.
When I will click on "Take me to Android Page Button", it should take
me to Natively designed Page of Android and when I will click on "Take
me to iOS Page Button" then it should take me to Natively designed
page in iOS Project.
You can first find out what Xamarin Forms is and how it works.
From document What is Xamarin.Forms?,we know:
Xamarin.Forms is an open-source UI framework. Xamarin.Forms allows
developers to build Xamarin.Android, Xamarin.iOS, and Windows
applications from a single shared codebase.
Xamarin.Forms allows developers to create user interfaces in XAML with
code-behind in C#. These interfaces are rendered as performant native
controls on each platform.
And part Who Xamarin.Forms is for mentions that :
Xamarin.Forms is for developers with the following goals:
Share UI layout and design across platforms
Share code, test and business logic across platforms.
Write cross-platform apps in C# with Visual Studio.
So, the requirement you mentioned above is not invalid.
In addition,if you want to use native controls of the target platform in xamarin forms, you can use Xamarin.Forms Custom Renderers to achieve this.
Xamarin.Forms user interfaces are rendered using the native controls
of the target platform, allowing Xamarin.Forms applications to retain
the appropriate look and feel for each platform. Custom Renderers let
developers override this process to customize the appearance and
behavior of Xamarin.Forms controls on each platform.
Note:
We have Payment Gateway SDK for Android specific only that's why we
need to use Native forms. Can you suggest or give me some hint how we
can use them ?
Xamarin.Android offers two ways to use these libraries:
1. Create a Bindings Library that automatically wraps the library with
C# wrappers so you can invoke Java code via C# calls.
2. Use the Java Native Interface (JNI) to invoke calls in Java library
code directly. JNI is a programming framework that enables Java code
to call and be called by native applications or libraries.
For more details, check: https://learn.microsoft.com/en-us/xamarin/android/platform/binding-java-library/ .

Audio recording in Xamarin.forms

I have a xamarin.forms project which has to record the audio and save it localy on the app.
Is there any plugin / api which can be used to achieve this?
Also I would like to know the source of the recorind ie. whether it is being recorded from microphone or is it from handsfree (speaker) without using microphone.
There is no plugin that I know of that does this. you could create a generic service interface called IRecorder which has the functionality you need and then implement the IRecorder interface in the platform specific projects using called AndroidRecorder etc using the dependency service
when implementing your platform specific code you can use these samples
Android
iOS
Windows 10
There is an open-source plugin for working with audio recorder in Xamarin.Forms :
https://github.com/NateRickard/Plugin.AudioRecorder
You can use the dependency service to access platform-specific APIs such as AVAudioRecorder on iOS or MediaRecorder on Android.

Can I use WPF's Full-screen UI on Xamarin?

I'm thinking about starting to use Xamarin, is it possible to take a full-screen WPF project and use it on iOS and Android ?
No. Xamarin.Android and Xamarin.iOS expose the UI of the relevant platforms - you can't just use WPF on them.
However, if you separate out your "business logic" from the UI logic in your application, you may well be able to use the same business logic project, and just create new UI projects (one per platform). Of course, that relies on your "business logic" only requiring functionality which is available on Xamarin; more generally you'd want to create a Portable Class Library with that code in.
No this is not possible. You have to use the Native API's for User Interface on both IOS and Android when you use Xamarin.
You can definitely share a lot of code, but WPF will not work.
No. Xamarin relies on each platform's native UI stack. You cannot take a WPF UI (or a Winforms or Silverlight UI) and run it on iOS or Android. What you CAN do is take the underlying core of your WPF project (domain, services, data, business logic) and use Xamarin to create an iOS and/or Android native UI on top of it.
WPF is only supported on Windows - it's not even supported on other platforms with desktop APIs for Mono.
In general, with Xamarin, the approach is you share "logic" code, but use native UI projects for each platform.

C#/Metro implementing background service

Is it possible to implement service that starts on startup and monitors users acitivity only using Metro WinRT and API? I need somehow figure out a way to get information that user started watching video. I know that it is possible to implement it in normal .NET (by kernel functions), but I would like to know whether this is possible on WinRT tablets. Maybe by creating some triggers.
Thanks
No, fortunately as Raymond said - it is not possible. You can monitor only applications that you create yourself with code that comes with them. Or you could create a library that does monitoring you want and ask developers of applications to use it - basically what vendors of analytics libraries would do.

wp7 add alarm entry

Is there a way to programmatically add an alarm entry from the app I am creating?
No, currently the SDK doesn't offer any capabilities to interact with systems applications like the Alarms app from a third-party application. I am sure there is a native hook for this (considering the way apps interact internally), but it's not publicly available right now.

Categories