Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
How to initialize bar code scanner on App startup.
Sajid Hussain
Dec 21 2017 12:35 AM
160
Reply
I have a requirement for my xamarin cross platform application that as soon as app start up .QR Scanner set in to read the code. on completing scanning a beep will be ring up.and app again ready for next scanning how can i get this done. what i have done is on button click scanner start, its read code, then i have to press button again to start it again.
public
HomePage()
{
Button scanBtn =
new
Button
{
Text =
"Scan Barcode"
,
HorizontalOptions = LayoutOptions.FillAndExpand,
};
scanBtn.Clicked += async (sender, args) =>
{
var scanResult = await Acr.BarCodes.BarCodes.Instance.Read();
if
(!scanResult.Success)
{
await
this
.DisplayAlert(
"Alert ! "
,
"Sorry ! \n Failed to read the Barcode !"
,
"OK"
);
}
else
{
var endpoint =
new
EndpointAddress(
"http://192.168.15.33/SMS/WebServices/SMSService.svc"
);
var binding =
new
BasicHttpBinding
{
Name =
"basicHttpBinding"
,
MaxBufferSize = 2147483647,
MaxReceivedMessageSize = 2147483647
};
TimeSpan timeout =
new
TimeSpan(0, 0, 30);
binding.SendTimeout = timeout;
binding.OpenTimeout = timeout;
binding.ReceiveTimeout = timeout;
_client =
new
SMSServiceClient(binding, endpoint);
_client.ValidateStudentAsync(
"123-admin"
);
_client.ValidateStudentCompleted += _client_ValidateStudentCompleted; ;
// await this.DisplayAlert("Scan Successful !", String.Format("Barcode Format : {0} \n Barcode Value : {1}", scanResult.Format, scanResult.Code), "OK");
}
};
Content =
new
StackLayout
{
Children = {
scanBtn
}
};
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
package restore failed
error while running windows mobile application