Xamarin forms detect upi:// URL and open installed UPI applications using PCL - c#

Is there any way to detect upi:// URL in Xamarin forms PCL? I have tried below code but no success yet.
Note: Not looking for android and iOS based solution in this case.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace xamaringformwithIntentUPI
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
MyWebview.Source = "https://payment1.atomtech.in/paynetz/epi/fts?login=1191&pass=NCA#1234&ttype=NBFundTransfer&prodid=NCA&amt=1.00&txncurr=INR&txnscamt=0&clientcode=007&txnid=T2&custacc=1234567890&date=26/06/2018&ru=https://payment.atomtech.in/paynetzclient/ResponseParam.jsp&signature=b8f1c0972cd5f664a5fb41e0b3e5860a3c3bfd66835e5635940cf38245b234063090669ad691b6d6265491bf0510ea07d890530bd5b6309d31c81294b8f122ce&udf2=sagar#gmail.com&udf3=8888888888";
MyWebview.Navigating += Webview_Navigating;
}
private void Webview_Navigating(object sender, WebNavigatingEventArgs e)
{
var url = e.Url;
Console.WriteLine("url detected = " + url);
if (url.StartsWith("upi://"))
{
Console.WriteLine("upi url detected = ");
Console.WriteLine(url);
}
}
}
}

Related

I'm using Gmap.net to show google maps on winforms but getting error 400 bad request. is there a way to fix it or either is there any alternative?

I'm trying to display a google map over winforms.
In my project I did : Tools > NuGET Package Manager > Manage NuGET packages for Solution... > Browse
type to search gmap and installed the top one version 2.1.7
then in form1 :
private void btnShowOnGoogleMaps_Click(object sender, EventArgs e)
{
GoogleMaps googleMaps = new GoogleMaps();
googleMaps.Show();
}
and in the GoogleMaps form :
using GMap.NET;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Weather
{
public partial class GoogleMaps : Form
{
public GoogleMaps()
{
InitializeComponent();
}
private void GoogleMaps_Load(object sender, EventArgs e)
{
gmap.MapProvider = GMap.NET.MapProviders.BingMapProvider.Instance;
GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerOnly;
gmap.SetPositionByKeywords("Paris, France");
}
}
}
then when running the application and clicking the button to show the google maps i'm getting this :

Call WebService With Xamarin Forms (Using Vs 2019)

Trying to Call WebService With Xamarin Forms
getting this error after run it
System.InvalidOperationException: 'A Binding must be configured for this channel factory
This is my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace And.Saby8
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Page1 : ContentPage
{
public Page1()
{
InitializeComponent();
login_ico.Source = ImageSource.FromResource("And.Saby8.image.logo.png");
btn_login.Clicked += Btn_login_Clicked;
}
public async void Btn_login_Clicked(object sender, EventArgs e)
{
myapp.myappSoapClient ws = new myapp.myappSoapClient();
login resulto = await ws.loginsAsync(username.Text, password.Text);
if (resulto.validuser)
await Navigation.PushAsync(new MainPage());
else
Device.BeginInvokeOnMainThread(() => {
DisplayAlert("Eror", "", "OK");
});
}
}
}
is there somthing wrong, is there alternative of Completed Event (loginsCompleted witch not available in vs2019)
Can you help me please ?
Thanks.

How to download file to specific location using WebClient's download

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
namespace Garfield
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
download("https://d1ejxu6vysztl5.cloudfront.net/comics/garfield/2019/2019-11-25.gif?v=1.1", "e.gif");
}
public void download(string link, string name)
{
using (WebClient Client = new WebClient())
{
Client.DownloadFile(link, name);
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
Using the code above I downloaded an image online, now how do I set the location of that file to somewhere else instead of it being in the debug folder?
This can be done through mentioning a valid desired location and name when download.
Client.DownloadFile("https://d1ejxu6vysztl5.cloudfront.net/comics/garfield/2019/2019-11-25.gif?v=1.1",
#"C:\yourfolder\yourfilename.png");
You can pass an entire path to your download method:
download("https://d1ejxu6vysztl5.cloudfront.net/comics/garfield/2019/2019-11-25.gif?v=1.1", "C:\\Users\\(You)\\Documents\\e.gif");
Just replace everything before "e.gif" with the path you desire.
See more here: https://learn.microsoft.com/en-us/dotnet/api/system.net.webclient.downloadfile?view=netframework-4.8

Error: SQLite Wrapper assembly for the current platform was not found

The structure of my application
Content mainpage
using MyBD;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel.Background;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace MyApp
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
}
private void button_Click(object sender, RoutedEventArgs e)
{
historyBD HBD = new historyBD("history");
}
}
}
Content MyBD
using SQLitePCL;
namespace MyBD
{
public class historyBD
{
public SQLiteConnection con;
private string mynull = "0";
public historyBD(string dbname)
{
con = new SQLiteConnection(dbname);
}
}
}
when you press the button , the line "con = new SQLiteConnection(dbname);"
gives an error message : "A SQLite Wrapper assembly for the current platform was not found. Ensure that the current project references both SQLitePCL and the following platform-specific assembly: SQLitePCL.Ext."
What am I doing wrong?

C# - Tier Separation - How to use these delegates?

Here's the relevant code:
ClickMeGame.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary
{
public class ClickMeGame
{
public OnClickMe onClickMeCallback;
public int score;
public ClickMeGame()
{
score = 0;
}
private void IncrementScore()
{
score++;
}
}
}
ClickMeCallBackDefinitions.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ClassLibrary
{
public delegate void OnClickMe();
}
MainWindow.cs (Windows Form)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ClassLibrary;
namespace ClickMe
{
public partial class mainWindow : Form
{
private ClickMeGame game;
public mainWindow()
{
InitializeComponent();
game = new ClickMeGame();
game.onClickMeCallback = clickMeButton_Click();
}
private void clickMeButton_Click(object sender, EventArgs e)
{
UpdateUI();
}
private void UpdateUI()
{
scoreLabel.Text = string.Format("The score is: {0}", game.score);
}
}
}
So what I'm trying to do is, when the user clicks a button present on the form, I want a label on the form to update with the game score which increments with every click.
I'm learning about/want to be able to do this with delegates in that I want to separate the project into 2 tiers; Presenation and Logic. I know it's unnecessary to do so, but I'd like to make it such that when you click the button, the Windows Form receives information about the game score via delegates/callback methods. I'm unsure how to do this, but I tried making the callback definition and referencing it, but I'm lost from there.
Assuming that the UI button uses the click event clickMeButton_Click then here you go.
public partial class mainWindow : Form
{
private ClickMeGame game;
public mainWindow()
{
InitializeComponent();
game = new ClickMeGame();
game.onClickMeCallback = param => UpdateUI();
}
private void clickMeButton_Click(object sender, EventArgs e)
{
game.onClickMeCallback.Invoke();
}
private void UpdateUI()
{
scoreLabel.Text = string.Format("The score is: {0}", game.score);
}
}

Categories