Mobile apps can be used as a tool for desktop apps to receive status information for desktop apps. Here's how to implement a simple Android program to receive the working status of a Windows scanner app.
Reference: How to Push notifications to Android applications from Windows
Ideas
Creating a socket connection for application communication
Start the background service on Android to receive information
After receiving the message, the backend service sends the push message to the Android app
Socket message Sending
Using TcpListener to create a socket connection, the relevant content can be consulted:Wireless TWAIN Document scanning on Android
Start Stop Android Service
To create a service Notificationservice:
public class notificationservice extends service { @ Override public void oncreate () { } @Override public void ondestroy () { } @Override public ibinder onbind (Intent intent) { return mBinder; } private final ibinder mbinder = new binder ( ) { @Override protected boolean ontransact (Int code, parcel data, parcel reply, int flags )  THROWS REMOTEEXCEPtion { return Super.ontransact (code, data, reply, flags); } };}
Declare this service in androidmanifest.xml :
<service android:name = "Com.dynamsoft.twain.NotificationService"/>
Start the service in onCreate (Bundle) :
StartService (New Intent (Scanassist.this, Notificationservice.class));
To stop the service in OnDestroy () :
StopService (New Intent (Scanassist.this, Notificationservice.class));
Push Android Notifications
Call Notificationmanager:
Private Notificationmanager MNM = (notificationmanager) getsystemservice (Notification_service);
Create Activity Incomingmessageviewfor content display:
public class incomingmessageview extends activity { public static final string key_from = "from"; public static final String KEY_MESSAGE = "MESSAGE"; public static final int NOTIFICATION_ID = R.layout.activity_main; @Override protected void oncreate (bundle savedinstancestate) { super.oncreate (savedinstancestate); textview view = new textview (This); view.settext (Getintent (). Getcharsequenceextra (Key_from) + ": " + getintent (). Getcharsequenceextra (key_message)); Setcontentview (view); &NBSP;&NBSP;&Nbsp; notificationmanager nm = (NotificationManager) Getsystemservice (Notification_service); nm.cancel (NOTIFICATION_ ID); }}
Declare activity in androidmanifest.xml :
<activity android:name= "Com.dynamsoft.twain.IncomingMessageView" android:label= "@string/app_name" ></activity>
Send a message and display it on the status bar:
Intent notifyintent = new Intent (this, incomingmessageview.class); Notifyintent.putextra (Incomingmessageview.key_ From, from); Notifyintent.putextra (Incomingmessageview.key_message, MESSAGE); Pendingintent pendingintent = pendingintent.getactivity (this, 0, notifyintent, Pending Intent.flag_one_shot); Notification Notif = new Notification.builder (this). Setcontenttitle ("TWAIN Scanner Status"). Setcontenttext (Message). Setsmallicon (R.drawable.ic_launcher). Setcontentintent (pendingintent). Setticker (Message). build (); Notif.defaults = Notification.default_all; Mnm.notify (incomingmessageview.notification_id, Notif);
Case
Run Android app, start service
Apps switch to the background to manipulate other applications, such as opening a browser
To manipulate apps on Windows, click File Scan
After the scan is successful, the message is sent to the phone
Source
Https://github.com/DynamsoftRD/ScanAssist
git clone https://github.com/DynamsoftRD/ScanAssist.git
How to send notification messages from Windows apps to Android apps