Skip to content

Instantly share code, notes, and snippets.

View TheAlphamerc's full-sized avatar
:electron:
React | Next | Node | Flutter | Xamarin

Sonu Sharma TheAlphamerc

:electron:
React | Next | Node | Flutter | Xamarin
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
@TheAlphamerc
TheAlphamerc / WriteFileInIOS.cs
Last active September 17, 2018 11:08
Code to write files in ios and then share
public void ShareLocalFile(string localFilePath, string title = "", object view = null)
{
try
{
if (string.IsNullOrWhiteSpace(localFilePath))
{
Console.WriteLine("Plugin.ShareFile: ShareLocalFile Warning: localFilePath null or empty");
return;
}
@TheAlphamerc
TheAlphamerc / API.md
Created September 17, 2018 12:03 — forked from particle4dev/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@TheAlphamerc
TheAlphamerc / CaptureScreen.cs
Created September 17, 2018 12:06
Capture Screenshot xamarin android
/// <summary>
/// Capture Screenshot xamarin android
/// </summary>
/// <returns> Byte[]</returns>
public async Task<byte[]> CaptureScreenAsync()
{
var activity = Forms.Context as Advantage.Swap.Droid.MainActivity;
if (activity == null)
{
return null;
@TheAlphamerc
TheAlphamerc / ConvertImageTOByteArray.cs
Created September 18, 2018 05:49
Convert Stream to byte array C#
/// <summary>
/// Convert stream to byte[]
/// </summary>
/// <param name="stream"></param>
/// <returns>Byte[]</returns>
public static byte[] ReadFully(Stream input)
{
byte[] buffer = new byte[16 * input.Length];
using (MemoryStream ms = new MemoryStream())
@TheAlphamerc
TheAlphamerc / GetMacAddress.cs
Created September 18, 2018 06:07
Code to get mac address in xamarin android
using Java.Net;
using Java.Util;
namespace Helpers
{
public class AndroidDevice
{
/// <summary>
/// Code to get mac address in xamarin android
/// </summary>
@TheAlphamerc
TheAlphamerc / GetDatabaseFilePath.cs
Created September 18, 2018 06:11
Code to return database path xamarin android
/// <summary>
/// Code to return database path xamarin android
/// </summary>
/// <returns>String path</returns>
public string DatabasePath()
{
var fileName = "AdvantageDb.db3";
var path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), fileName);
if (!File.Exists(path))
@TheAlphamerc
TheAlphamerc / EncryptDecryptString.cs
Last active September 18, 2018 06:29
Code to encrypt/decrypt string using key
using System;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Text;
namespace Helpers
{
public class EncryptData
{
/// <summary>
@TheAlphamerc
TheAlphamerc / WebApiRestClient.cs
Last active October 30, 2018 08:45
Consume Rest Client API Service Xamarin Form
using Newtonsoft.Json;
using System;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace ApiServices
{
public class WebApiRestClient
@TheAlphamerc
TheAlphamerc / AutoCapitalization.xaml
Created September 18, 2018 09:26
Sometimes you don’t want the mobile keyboard to capitalize the user’s entry. For example, when entering a username or email address. You can now control capitalization via an additional keyboard flag. Done via XAML it looks like this:
<Entry Placeholder="Enter your text" HeightRequest="40">
<Entry.Keyboard>
<Keyboard x:FactoryMethod="Create">
<x:Arguments>
<KeyboardFlags>CapitalizeNone</KeyboardFlags>
</x:Arguments>
</Keyboard>
</Entry.Keyboard>
</Entry>