I used Leadtools SDK for Barcode reader , when i try to get current activity it gives me null
This is my code
Stream resourceStream = new MemoryStream();
// Droid.MainActivity activity = Forms.Context as Droid.MainActivity;
var activity = Android.App.Application.Context as Activity;
int resId = activity.Resources.GetIdentifier("Datamatrix", "drawable", "com.companyname.UDOSE");
resourceStream = activity.Resources.OpenRawResource(resId);
var leadStream = LeadStream.Factory.FromStream(resourceStream);
await ReadBarcode(leadStream);
activity always null , how can i solve this ?
1.define a global static Acitivity,in MainActivity :
when you use call
MainActivity.Instance2.use the Current Activity Plugin,you could refer to Current Activity
3.i suggest you use DependencyService to call the method which was defined in Droid project,like:
create a Interface in sharecode:
then in Droid project create a class:
and call in page.xmal.cs like
DependencyService.Get<IRead>().Read();