-1
私のxamarinクロスプラットフォームアプリケーションには、アプリケーションを起動するとすぐに.QRスキャナがコードを読み取るように設定されています。ビープ音を鳴らすと音が鳴り、次回のスキャンの準備が整う。私がやったことは、ボタンをクリックしてスキャナのスタート、そのコードを読むことです、そして、私はもう一度ボタンを押す必要があります。アプリケーションの起動時にバーコードスキャナを初期化する方法
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
}
};
}
とapp.cs
public class App : Application
{
public App()
{
// The root page of your application
MainPage = new HomePage();
}
protected override void OnStart()
{
MainPage = new HomePage();
}
protected override void OnSleep()
{
MainPage = new HomePage();
}
protected override void OnResume()
{
MainPage = new HomePage();
}
}
非常に素晴らしく、正確な。一歩先を向いて、ビープ音を鳴らしたり、カードホルダーに声をかける方法はありますか? – SajidH
回答として役立つ場合は、[XamarinAudioManager NuGet Package](https://www.nuget.org/packages/XamarinAudioManager)をインストールしてください。 –