c# - Datawedge scanning application Xamarin not working -


i'm trying make app xamarin , datawedge i'm running alot of difficulties.

first off tried so:

[activity(label = "scanner.app", icon = "@drawable/icon", mainlauncher = true, configurationchanges = configchanges.screensize | configchanges.orientation, screenorientation = screenorientation.portrait)] [intentfilter(new string[] { "barcodescanner.recvr" }, categories = new[] { intent.categorydefault })] public class mainactivity : global::xamarin.forms.platform.android.formsapplicationactivity {     // intent string contains source of data string       private static string source_tag = "com.motorolasolutions.emdk.datawedge.source";     // intent string contains barcode symbology string       private static string label_type_tag = "com.motorolasolutions.emdk.datawedge.label_type";     // intent string contains captured data string       // (in case of msr data string contains concatenation of track data)       private static string data_string_tag = "com.motorolasolutions.emdk.datawedge.data_string";     // intent action our operation     private static string ourintentaction = "barcodescanner.recvr";      // let's define api intent strings soft scan trigger     private static string action_softscantrigger = "com.motorolasolutions.emdk.datawedge.api.action_softscantrigger";     private static string extra_param = "com.motorolasolutions.emdk.datawedge.api.extra_parameter";     private static string dwapi_toggle_scanning = "toggle_scanning";      protected override void oncreate(bundle bundle)     {         base.oncreate(bundle);          global::xamarin.forms.forms.init(this, bundle);         loadapplication(new app());     }      private void handledecodedata(intent i)     {         // check intent action           if (i.action.equals(ourintentaction))         {             // define string hold our output               string out = "";             // source of data               string source = i.getstringextra(source_tag);             // save use later               if (source == null) source = "scanner";             // data intent               string data = i.getstringextra(data_string_tag);             // let's define variable data length                 int data_len = 0;             // , set length of data               if (data != null) data_len = data.length;             // check if data has come barcode scanner               if (source.equals("scanner"))             {                 // check if there in data                   if (data != null && data.length > 0)                 {                     // have data, let's it's symbology                       string slabeltype = i.getstringextra(label_type_tag);                     // check if string empty                       if (slabeltype != null && slabeltype.length > 0)                     {                        // format of label type string label-type-symbology                           // let's skip label-type- portion symbology                           slabeltype = slabeltype.substring(11);                     }                     else                     {                         // string empty let's set "unknown"                           slabeltype = "unknown";                     }                       // let's construct beginning of our output string                       out = "source: scanner, " + "symbology: " + slabeltype + ", length: " + data_len.tostring() + ", data: ...\r\n";                 }             }             // check if data has come msr               if (source.equals("msr"))             {                 // construct beginning of our output string                   out = "source: msr, length: " + data_len.tostring() + ", data: ...\r\n";             }              // need put edit box text spannable string builder               spannablestringbuilder stringbuilder = new spannablestringbuilder();             // add output string constructed earlier               stringbuilder.append(out);             // let's highlight our output string in bold type               //stringbuilder.setspan(new stylespan(typeface.defaultbold), et.text.length, stringbuilder.length, spannablestring.span_exclusive_exclusive);               // add barcode or msr data, plus new line, , add string builder               stringbuilder.append(data + "\r\n");         }     }      protected override void onnewintent(intent intent)     {         handledecodedata(intent);     } 

what lead me difficulty of when scan something, oncreate getting called lead new instance of application, not okay. onnewintentshould have been called never triggered.

the second try on problem

[activity(label = "scanner.app", name ="com.creonis.scanner.mainactivity", icon = "@drawable/icon", mainlauncher = true,      configurationchanges = configchanges.screensize | configchanges.orientation, screenorientation = screenorientation.portrait)] public class mainactivity : global::xamarin.forms.platform.android.formsapplicationactivity {     protected override void oncreate(bundle bundle)     {         base.oncreate(bundle);          scanreceiver _broadcastreceiver = new scanreceiver();          global::xamarin.forms.forms.init(this, bundle);         var my_application = new app();         _broadcastreceiver.scandatareceived += (s, scandata) =>         {          };          // register broadcast receiver         intentfilter filter = new intentfilter(scanreceiver.intentaction);         filter.addcategory(scanreceiver.intentcategory);         this.registerreceiver(_broadcastreceiver, filter);          loadapplication(my_application);      }  [broadcastreceiver(enabled = true)] public class scanreceiver : broadcastreceiver {     // intent string contains source of data string       private static string source_tag = "com.motorolasolutions.emdk.datawedge.source";     // intent string contains barcode symbology string       private static string label_type_tag = "com.motorolasolutions.emdk.datawedge.label_type";     // intent string contains captured data string       // (in case of msr data string contains concatenation of track data)       private static string data_string_tag = "com.motorolasolutions.emdk.datawedge.data_string";     // intent action our operation     public static string intentaction = "barcodescanner.recvr";     public static string intentcategory = "android.intent.category.default";      public event eventhandler<string> scandatareceived;      public override void onreceive(context context, intent i)     {         // check intent action           if (i.action.equals(intentaction))         {             // define string hold our output               string out = "";             // source of data               string source = i.getstringextra(source_tag);             // save use later               if (source == null)                 source = "scanner";             // data intent               string data = i.getstringextra(data_string_tag);             // let's define variable data length               int data_len = 0;             // , set length of data               if (data != null)                 data_len = data.length;             // check if data has come barcode scanner               if (source.equals("scanner"))             {                 // check if there in data                   if (data != null && data.length > 0)                 {                     // have data, let's it's symbology                       string slabeltype = i.getstringextra(label_type_tag);                     // check if string empty                       if (slabeltype != null && slabeltype.length > 0)                     {                         // format of label type string label-type-symbology                           // let's skip label-type- portion symbology                           slabeltype = slabeltype.substring(11);                     }                     else {                         // string empty let's set "unknown"                           slabeltype = "unknown";                     }                      // let's construct beginning of our output string                       out = "scanner  " + "symbology: " + slabeltype + ", length: " + data_len.tostring() + ", data: " + data.tostring() + "\r\n";                 }             }             // check if data has come msr               if (source.equals("msr"))             {                 // construct beginning of our output string                   out = "source: msr, length: " + data_len.tostring() + ", data: " + data.tostring() + "\r\n";             }               if (scandatareceived != null)             {                 scandatareceived(this, out);             }         }     } } 

which lead me problem of nothing happening when scan something.

can point me in right direction because i'm out of idea's try.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -