kandi background
Explore Kits

xamarin-android | Android provides open-source bindings | Android library

 by   xamarin C# Version: v11.2.99.192 License: Non-SPDX

 by   xamarin C# Version: v11.2.99.192 License: Non-SPDX

Download this library from

kandi X-RAY | xamarin-android Summary

xamarin-android is a C# library typically used in Mobile, Android, Xamarin applications. xamarin-android has no bugs, it has no vulnerabilities and it has medium support. However xamarin-android has a Non-SPDX License. You can download it from GitHub.
Xamarin.Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • xamarin-android has a medium active ecosystem.
  • It has 1695 star(s) with 502 fork(s). There are 167 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 605 open issues and 1505 have been closed. On average issues are closed in 58 days. There are 55 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of xamarin-android is v11.2.99.192
xamarin-android Support
Best in #Android
Average in #Android
xamarin-android Support
Best in #Android
Average in #Android

quality kandi Quality

  • xamarin-android has 0 bugs and 0 code smells.
xamarin-android Quality
Best in #Android
Average in #Android
xamarin-android Quality
Best in #Android
Average in #Android

securitySecurity

  • xamarin-android has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • xamarin-android code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
xamarin-android Security
Best in #Android
Average in #Android
xamarin-android Security
Best in #Android
Average in #Android

license License

  • xamarin-android has a Non-SPDX License.
  • Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.
xamarin-android License
Best in #Android
Average in #Android
xamarin-android License
Best in #Android
Average in #Android

buildReuse

  • xamarin-android releases are available to install and integrate.
  • Installation instructions are available. Examples and code snippets are not available.
  • xamarin-android saves you 1740 person hours of effort in developing the same functionality from scratch.
  • It has 3963 lines of code, 170 functions and 1637 files.
  • It has low code complexity. Code complexity directly impacts maintainability of the code.
xamarin-android Reuse
Best in #Android
Average in #Android
xamarin-android Reuse
Best in #Android
Average in #Android
Top functions reviewed by kandi - BETA

kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here

Get all kandi verified functions for this library.

Get all kandi verified functions for this library.

xamarin-android Key Features

Xamarin.Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#

Application does't buil whit Android 12 (Firebase.Messaging)

copy iconCopydownload iconDownload
<service android:enabled="true" android:name=".CustomFirebaseMessagingService" android:exported="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT"/>
        </intent-filter>
    </service>

MAUI: What build action for appsettings.json and how to access the file on Android?

copy iconCopydownload iconDownload
var builder = MauiApp.CreateBuilder();
        builder
            .RegisterBlazorMauiWebView()
            .UseMauiApp<App>()
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
            })
            .Host
            .ConfigureAppConfiguration((app, config) =>
            {
                var assembly = typeof(App).GetTypeInfo().Assembly;
                config.AddJsonFile(new EmbeddedFileProvider(assembly), "appsettings.json", optional: false, false);
            });
var builder = MauiApp.CreateBuilder();

var assembly = Assembly.GetExecutingAssembly();

// appsettings.json is located directly under MyNamespace.csproj
using var stream = assembly.GetManifestResourceStream("MyNamespace.appsettings.json");
stream.Position = 0;
var appSettings = System.Text.Json.JsonSerializer.Deserialize<AppSettings>(stream);

builder.Services.AddSingleton(appSettings)

Xamarin Forms Release Problem: Mono.Linker.MarkException: Error processing method: 'System.String Microsoft.Net.Http.Headers.DateTimeFormatter

copy iconCopydownload iconDownload
public class LinkerPleaseInclude
{
  public void KeepInplaceStringBuilder(Microsoft.Extensions.Primitives.InplaceStringBuilder x)
  {
    x.Append('x'); // This will keep the InplaceStringBuilder.Append method from being linked out...
  }
}
<linker>
        <assembly fullname="Microsoft.Net.Http.Headers">
                <type fullname="Microsoft.Extensions.Primitives.InplaceStringBuilder">
        </assembly>
</linker>
public class LinkerPleaseInclude
{
  public void KeepInplaceStringBuilder(Microsoft.Extensions.Primitives.InplaceStringBuilder x)
  {
    x.Append('x'); // This will keep the InplaceStringBuilder.Append method from being linked out...
  }
}
<linker>
        <assembly fullname="Microsoft.Net.Http.Headers">
                <type fullname="Microsoft.Extensions.Primitives.InplaceStringBuilder">
        </assembly>
</linker>

Unable to add pdf and doc files using Recent files using Xamarin.Plugin.Filepicker

copy iconCopydownload iconDownload
async Task<FileResult> PickAndShow(PickOptions options)
{
    try
    {
        var result = await FilePicker.PickAsync(options);
        if (result != null)
        {
            Text = $"File Name: {result.FileName}";
            if (result.FileName.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) ||
                result.FileName.EndsWith("png", StringComparison.OrdinalIgnoreCase))
            {
                var stream = await result.OpenReadAsync();
                Image = ImageSource.FromStream(() => stream);
            }
        }
        
        return result;
    }
    catch (Exception ex)
    {
        // The user canceled or something went wrong
    }
    
    return null;
}

Run my app when a file with custom extension is selected (and do something)

copy iconCopydownload iconDownload
 [IntentFilter(new[] { Android.Content.Intent.ActionView }, 
Categories = new[] { Android.Content.Intent.CategoryDefault }, 
DataMimeType = "application/*", DataPathPattern = "*.Dinero")]
if ( Intent.Action== Android.Content.Intent.ActionView)
{
      string filecontent = GetFileContent(Intent);
}
string GetFileContent(Android.Content.Intent Intent)
        {
            Android.Net.Uri uridata = Intent.Data;
            StreamReader streamread = new StreamReader(ContentResolver.OpenInputStream(uridata));
            string content = streamread.ReadToEnd();
            return content;
        }
 [IntentFilter(new[] { Android.Content.Intent.ActionView }, 
Categories = new[] { Android.Content.Intent.CategoryDefault }, 
DataMimeType = "application/*", DataPathPattern = "*.Dinero")]
if ( Intent.Action== Android.Content.Intent.ActionView)
{
      string filecontent = GetFileContent(Intent);
}
string GetFileContent(Android.Content.Intent Intent)
        {
            Android.Net.Uri uridata = Intent.Data;
            StreamReader streamread = new StreamReader(ContentResolver.OpenInputStream(uridata));
            string content = streamread.ReadToEnd();
            return content;
        }
 [IntentFilter(new[] { Android.Content.Intent.ActionView }, 
Categories = new[] { Android.Content.Intent.CategoryDefault }, 
DataMimeType = "application/*", DataPathPattern = "*.Dinero")]
if ( Intent.Action== Android.Content.Intent.ActionView)
{
      string filecontent = GetFileContent(Intent);
}
string GetFileContent(Android.Content.Intent Intent)
        {
            Android.Net.Uri uridata = Intent.Data;
            StreamReader streamread = new StreamReader(ContentResolver.OpenInputStream(uridata));
            string content = streamread.ReadToEnd();
            return content;
        }

Android Local Notification BootReceiver not working

copy iconCopydownload iconDownload
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
[BroadcastReceiver(
    Enabled = true,
    Permission = "android.permission.RECEIVE_BOOT_COMPLETED",
    Exported = true)]
[IntentFilter(new []
{
    "android.intent.action.BOOT_COMPLETED", 
    "android.intent.action.QUICKBOOT_POWERON", 
    "com.htc.intent.action.QUICKBOOT_POWERON"
}, Categories = new []{ "android.intent.category.DEFAULT" })]
public class MyRebootReceiver : BroadcastReceiver
{
    private const string NotificationChannelId = "boot_notifications";
    private const int NotificationId = 1000;
    
    public override void OnReceive(Context? context, Intent? intent)
    {
        Log.Info("MyRebootReceiver", "Got intent");
        
        var notificationManager = (NotificationManager) context?.GetSystemService(Context.NotificationService);
        SetupNotificationChannel(notificationManager);
        
        var resultIntent = new Intent(context, typeof(MainActivity));
        var stackBuilder = TaskStackBuilder.Create(context);
        stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
        stackBuilder.AddNextIntent(resultIntent);

        // Create the PendingIntent with the back stack:
        var resultPendingIntent = stackBuilder.GetPendingIntent(0, (int) PendingIntentFlags.UpdateCurrent);

        var notification = new NotificationCompat.Builder(context, NotificationChannelId)
            .SetContentTitle("Device Rebooted")
            .SetContentText("Your device rebooted")
            .SetSmallIcon(Resource.Drawable.ic_stat_accessibility_new)
            .SetContentIntent(resultPendingIntent);
            
        notificationManager?.Notify(NotificationId, notification.Build());
    }
    
    private void SetupNotificationChannel(NotificationManager notificationManager)
    {
        if (Build.VERSION.SdkInt < BuildVersionCodes.O) return;

        var channel = new NotificationChannel(NotificationChannelId, "Boot Notifications",
            NotificationImportance.Default)
        {
            Description = "Channel for receiving boot notifications"
        };
            
        notificationManager.CreateNotificationChannel(channel);
    }
}
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
[BroadcastReceiver(
    Enabled = true,
    Permission = "android.permission.RECEIVE_BOOT_COMPLETED",
    Exported = true)]
[IntentFilter(new []
{
    "android.intent.action.BOOT_COMPLETED", 
    "android.intent.action.QUICKBOOT_POWERON", 
    "com.htc.intent.action.QUICKBOOT_POWERON"
}, Categories = new []{ "android.intent.category.DEFAULT" })]
public class MyRebootReceiver : BroadcastReceiver
{
    private const string NotificationChannelId = "boot_notifications";
    private const int NotificationId = 1000;
    
    public override void OnReceive(Context? context, Intent? intent)
    {
        Log.Info("MyRebootReceiver", "Got intent");
        
        var notificationManager = (NotificationManager) context?.GetSystemService(Context.NotificationService);
        SetupNotificationChannel(notificationManager);
        
        var resultIntent = new Intent(context, typeof(MainActivity));
        var stackBuilder = TaskStackBuilder.Create(context);
        stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(MainActivity)));
        stackBuilder.AddNextIntent(resultIntent);

        // Create the PendingIntent with the back stack:
        var resultPendingIntent = stackBuilder.GetPendingIntent(0, (int) PendingIntentFlags.UpdateCurrent);

        var notification = new NotificationCompat.Builder(context, NotificationChannelId)
            .SetContentTitle("Device Rebooted")
            .SetContentText("Your device rebooted")
            .SetSmallIcon(Resource.Drawable.ic_stat_accessibility_new)
            .SetContentIntent(resultPendingIntent);
            
        notificationManager?.Notify(NotificationId, notification.Build());
    }
    
    private void SetupNotificationChannel(NotificationManager notificationManager)
    {
        if (Build.VERSION.SdkInt < BuildVersionCodes.O) return;

        var channel = new NotificationChannel(NotificationChannelId, "Boot Notifications",
            NotificationImportance.Default)
        {
            Description = "Channel for receiving boot notifications"
        };
            
        notificationManager.CreateNotificationChannel(channel);
    }
}

Android emulator doesn't work: Failed to open /qemu.conf, No accelerator found and more

copy iconCopydownload iconDownload
PS C:\Program Files (x86)\Android\android-sdk\emulator> .\emulator-check.exe accel
accel:
0
HAXM version 7.7.0 (4) is installed and usable.
accel

How can I correctly exclude some libraries so that they are not linked in Xamarin.Android?

copy iconCopydownload iconDownload
 #pragma warning disable 0219, 0649
     static bool falseflag = false;
     static MaterialSearchBar ()
     {
         if (falseflag) {
             var ignore = new AnimatedVectorDrawable ();
         }
     }

How do I autoincrement Xamarin Android build and version numbers in Azure Pipelines?

copy iconCopydownload iconDownload
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="string"
          android:sharedUserId="string"
          android:sharedUserLabel="string resource" 
          android:versionCode="integer"
          android:versionName="string"
          android:installLocation=["auto" | "internalOnly" | "preferExternal"] >
    . . .
</manifest>
variables:
  major: 1
  number: $[counter(variables['major'], 100)]

steps:
- bash: echo $(minor)
- task: qetza.replacetokens.replacetokens-task.replacetokens@3
  displayName: 'Replace tokens'
  inputs:
    targetFiles: |
      **/AndroidManifest.xml 
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="string"
          android:sharedUserId="string"
          android:sharedUserLabel="string resource" 
          android:versionCode="#{number}#"
          android:versionName="string"
          android:installLocation=["auto" | "internalOnly" | "preferExternal"] >
    . . .
</manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="string"
          android:sharedUserId="string"
          android:sharedUserLabel="string resource" 
          android:versionCode="integer"
          android:versionName="string"
          android:installLocation=["auto" | "internalOnly" | "preferExternal"] >
    . . .
</manifest>
variables:
  major: 1
  number: $[counter(variables['major'], 100)]

steps:
- bash: echo $(minor)
- task: qetza.replacetokens.replacetokens-task.replacetokens@3
  displayName: 'Replace tokens'
  inputs:
    targetFiles: |
      **/AndroidManifest.xml 
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="string"
          android:sharedUserId="string"
          android:sharedUserLabel="string resource" 
          android:versionCode="#{number}#"
          android:versionName="string"
          android:installLocation=["auto" | "internalOnly" | "preferExternal"] >
    . . .
</manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="string"
          android:sharedUserId="string"
          android:sharedUserLabel="string resource" 
          android:versionCode="integer"
          android:versionName="string"
          android:installLocation=["auto" | "internalOnly" | "preferExternal"] >
    . . .
</manifest>
variables:
  major: 1
  number: $[counter(variables['major'], 100)]

steps:
- bash: echo $(minor)
- task: qetza.replacetokens.replacetokens-task.replacetokens@3
  displayName: 'Replace tokens'
  inputs:
    targetFiles: |
      **/AndroidManifest.xml 
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="string"
          android:sharedUserId="string"
          android:sharedUserLabel="string resource" 
          android:versionCode="#{number}#"
          android:versionName="string"
          android:installLocation=["auto" | "internalOnly" | "preferExternal"] >
    . . .
</manifest>

Xamarin forms resx localization always return default language

copy iconCopydownload iconDownload
 <Target Name="_ResolveSatellitePaths"
DependsOnTargets="_ResolveAssemblies">
<ResolveAssemblyReference
    AllowedAssemblyExtensions="$(AllowedReferenceAssemblyFileExtensions)"
    AssemblyFiles="@(ResolvedUserAssemblies)"
    AutoUnify="$(AutoUnifyAssemblyReferences)"
    FindDependencies="True"
    FindRelatedFiles="False"
    FindSatellites="True"
    SearchPaths="$(AssemblySearchPaths)"
    TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
    TargetFrameworkMonikerDisplayName="$(TargetFrameworkMonikerDisplayName)"
    TargetFrameworkDirectories="$(TargetFrameworkDirectory)">
  <Output TaskParameter="SatelliteFiles" ItemName="_AndroidResolvedSatellitePaths"/>
</ResolveAssemblyReference>

Community Discussions

Trending Discussions on xamarin-android
  • Xamarin Forms Shell Navigation Failure with System.NullReferenceException
  • Application does't buil whit Android 12 (Firebase.Messaging)
  • MAUI: What build action for appsettings.json and how to access the file on Android?
  • How to SAFELY invoke java keytool from C# code
  • Xamarin Forms Release Problem: Mono.Linker.MarkException: Error processing method: 'System.String Microsoft.Net.Http.Headers.DateTimeFormatter
  • Creating a Xamarin.Android project using .NET 6
  • Error compiling Xamarin Application on Release mode: System.InvalidOperationException: Sequence contains no elements
  • Unable to add pdf and doc files using Recent files using Xamarin.Plugin.Filepicker
  • Run my app when a file with custom extension is selected (and do something)
  • Is it possible to add an Android widget to app in Uno Platform?
Trending Discussions on xamarin-android

QUESTION

Xamarin Forms Shell Navigation Failure with System.NullReferenceException

Asked 2022-Apr-11 at 05:42

This is a sample application attempting the Xamarin Forms navigation capability. We have an event handler with this simple logic:

async void Button_Clicked(System.Object sender, System.EventArgs e)
{
    await Shell.Current.GoToAsync(nameof(SchoolList));
}

We also have the route registered in App.xaml.cs as follows:

public partial class App : Application
    {
        public App()
        {
            InitializeComponent();

            MainPage = new MainPage();
            Routing.RegisterRoute(nameof(SchoolList), typeof(SchoolList));
        }

However, when the corresponding button is clicked, we get the error below:

System.NullReferenceException: Object reference not set to an instance of an object.
  at cross_app1.MainPage.Button_Clicked (System.Object sender, System.EventArgs e) [0x0000f] in /Users/klaus.nji/Projects/cross-app1/cross-app1/MainPage.xaml.cs:18
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
  at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in /Users/builder/azdo/_work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-30/mcw/Java.Lang.IRunnable.cs:84
  at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.39(intptr,intptr)

The system is Mac Catalina v10.15.7, IDE is Visual Studio 2019 for Mac and I have the Andriod SDK installed and able to see other aspects of the app.

ANSWER

Answered 2022-Apr-11 at 05:40

It looks like you don’t have a Shell, so Shell.Current is null. What Shell example did you follow?

MainPage = new MainPage(); means your app is pointing to a page of type MainPage. To use Shell (Route) navigation, it needs to be pointing to a Shell.

I would expect to see MainPage = new AppShell();.

There may be other details missing, so be sure to follow a working example, such as Xaminals.

The new AppShell line can be seen in https://github.com/xamarin/xamarin-forms-samples/blob/main/UserInterface/Xaminals/Xaminals/App.xaml.cs.

Note: Its possible to navigate in Xamarin Forms without having Shell, nor defining routes. (Personally, I dislike the Shell, so I don’t use it.) You can define MainPage as a NavigationPage (see its doc). Or you can simply set App.MainPage to different pages, to move between them, without a navigation stack.

Source https://stackoverflow.com/questions/71822640

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install xamarin-android

| Platform | Status | |-----------------------|--------| | OSS macOS | [![OSS macOS x86_64][oss-macOS-x86_64-icon]][oss-macOS-x86_64-status] | | OSS Ubuntu | [![OSS Linux/Ubuntu x86_64][oss-ubuntu-x86_64-icon]][oss-ubuntu-x86_64-status] |. [oss-macOS-x86_64-icon]: https://dev.azure.com/xamarin/public/_apis/build/status/xamarin/xamarin-android/Xamarin.Android-OSS?branchName=main&stageName=Mac [oss-macOS-x86_64-status]: https://dev.azure.com/xamarin/public/_build/latest?definitionId=48&branchName=main&stageName=Mac [oss-ubuntu-x86_64-icon]: https://dev.azure.com/xamarin/public/_apis/build/status/xamarin/xamarin-android/Xamarin.Android-OSS?branchName=main&stageName=Linux [oss-ubuntu-x86_64-status]: https://dev.azure.com/xamarin/public/_build/latest?definitionId=48&branchName=main&stageName=Linux.

Support

If you are interested in fixing issues and contributing directly to the code base, please see the following:. This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the [.NET Foundation Code of Conduct](http://www.dotnetfoundation.org/code-of-conduct).

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Reuse Pre-built Kits with xamarin-android
Consider Popular Android Libraries
Try Top Libraries by xamarin
Compare Android Libraries with Highest Support
Compare Android Libraries with Highest Quality
Compare Android Libraries with Highest Security
Compare Android Libraries with Permissive License
Compare Android Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.