Skip to content

Commit

Permalink
v1.2-"com.symbol.datawedge.api.GET_ACTIVE_PROFILE" added
Browse files Browse the repository at this point in the history
  • Loading branch information
NDZL committed Nov 2, 2024
1 parent 0899427 commit 5b8d905
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 17 deletions.
7 changes: 7 additions & 0 deletions datawedge-MAUI-SampleApp/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@
HorizontalOptions="Center" />
</HorizontalStackLayout>

<Button
x:Name="DwACTIVEPROFILE"
Text="DW ACTIVE PROFILE"
SemanticProperties.Hint="Get DW Active Profile"
Clicked="OnDWGetActiveProfile"
HorizontalOptions="Center" />

</VerticalStackLayout>
</ScrollView>

Expand Down
6 changes: 6 additions & 0 deletions datawedge-MAUI-SampleApp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ private void OnDWONClicked(object sender, EventArgs e)
{
WeakReferenceMessenger.Default.Send("22");
WeakReferenceMessenger.Default.Send("SWITCHING ON DW");
}

private void OnDWGetActiveProfile(object sender, EventArgs e)
{
WeakReferenceMessenger.Default.Send("33");
WeakReferenceMessenger.Default.Send("GETTING ACTIVE PROFILE");
}
}

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ndzl.dwmaui">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ndzl.dwmaui" android:versionName="1.2">

</application>
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="33" />
Expand Down
49 changes: 38 additions & 11 deletions datawedge-MAUI-SampleApp/Platforms/Android/DWIntentReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,56 @@
using CommunityToolkit.Mvvm.Messaging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace datawedge_MAUI_SampleApp.Platforms.Android
{

[BroadcastReceiver(Enabled = true, Exported =true)]
[IntentFilter(new[] { "com.ndzl.DW" })]
public class DWIntentReceiver : BroadcastReceiver
[BroadcastReceiver(Enabled = true, Exported =true)]
public class DWIntentReceiver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
//System.Console.WriteLine("Here is DW on MAUI");
if (intent.Extras != null)
{
String bc_type = intent.Extras.GetString("com.symbol.datawedge.label_type");
String bc_data = intent.Extras.GetString("com.symbol.datawedge.data_string");

WeakReferenceMessenger.Default.Send(bc_type + " "+ bc_data);
}
System.Console.WriteLine("Here is DW on MAUI");
if (intent.Extras != null)
{
if (intent.HasExtra("com.symbol.datawedge.label_type")) {
String bc_type = intent.Extras.GetString("com.symbol.datawedge.label_type");
String bc_data = intent.Extras.GetString("com.symbol.datawedge.data_string");

WeakReferenceMessenger.Default.Send(bc_type + " " + bc_data);
}
else if (intent.HasExtra("com.symbol.datawedge.api.RESULT_GET_ACTIVE_PROFILE"))
{
String activeProfile = intent.Extras.GetString("com.symbol.datawedge.api.RESULT_GET_ACTIVE_PROFILE");

try
{
WeakReferenceMessenger.Default.Send("ACTIVE PROFILE=<" + activeProfile + ">");
}
catch (Exception e) { }
}
else if (intent.HasExtra("com.symbol.datawedge.api.RESULT_GET_PROFILES_LIST"))
{
String[] profilesList = intent.Extras.GetStringArray("com.symbol.datawedge.api.RESULT_GET_PROFILES_LIST");

try
{
WeakReferenceMessenger.Default.Send("profilesList size =<" + profilesList.Length + ">");
}
catch (Exception e) { }
}

}





}
Expand Down
14 changes: 11 additions & 3 deletions datawedge-MAUI-SampleApp/Platforms/Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,22 @@ protected override void OnPostCreate(Bundle savedInstanceState)
i.PutExtra("COMMAND_IDENTIFIER", "MY_DISABLE_SCANNER"); //Unique identifier
this.SendBroadcast(i);
}
else if (li=="22") {
else if (li == "22") {
Intent i = new Intent();
i.SetAction("com.symbol.datawedge.api.ACTION");
i.PutExtra("com.symbol.datawedge.api.SCANNER_INPUT_PLUGIN", "ENABLE_PLUGIN");
i.PutExtra("SEND_RESULT", "true");
i.PutExtra("COMMAND_IDENTIFIER", "MY_ENABLE_SCANNER"); //Unique identifier
this.SendBroadcast(i);
}
else if (li == "33") {

global::Android.Content.Intent i = new global::Android.Content.Intent();
i.SetAction("com.symbol.datawedge.api.ACTION");
i.PutExtra("com.symbol.datawedge.api.GET_ACTIVE_PROFILE", "" );
//i.PutExtra("com.symbol.datawedge.api.GET_PROFILES_LIST", "" );
SendBroadcast(i);
}

});
});
Expand Down Expand Up @@ -74,8 +82,8 @@ void RegisterReceivers()
IntentFilter filter = new IntentFilter();
filter.AddCategory("android.intent.category.DEFAULT");
filter.AddAction("com.ndzl.DW");
filter.AddAction("com.zebra.sensors");

filter.AddAction("com.symbol.datawedge.api.RESULT_ACTION");
Intent regres = RegisterReceiver(new DWIntentReceiver(), filter);
}
}

0 comments on commit 5b8d905

Please sign in to comment.