Issue
I'm trying to migrate my Xamarin project to Maui and I got stuck on finding the equivalent namespace to Android.App.Application.Context on Maui project. The DatabaseHelper class has the following path: MyProject -> Platforms -> Android -> Helpers.
Does anyone know what is the equivalent namespace to Android.App.Application.Context on Maui?
Thanks!
Solution
The error message is (indirectly) telling you what is wrong:
The type or namespace name 'App' does not exist in the namespace 'AAT.Platforms.Android'.
This is happening because you are in namespace AAT.Platforms.Android.Helpers, which means that Android is assumed to mean AAT.Platforms.Android.
Here are two ways to access Android.App.Application.Context in this situation:
global::Android.App.Application.ContextORusing AndroidApp = Android.App.Application;
AndroidApp.Context
Answered By - ToolmakerSteve
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.