Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

How to use Android Service(TAndroidService) in C++Builder

Author: h.mohri

[Make a new project for Android service.]

File→New→Other

NewItems→Delphi Project→Android Service.

After making the above selection, click OK.

 

Select a “Local Service” and click OK.

TDM class that inherits TAndroidService will be created.

Place the TNotificationCenter.

Create an OnStartCommand event and write the code.

[crayon-67402b3345dc7471861780/]

I saved it with the name p1.

 


 

[Create a C++Builder project]

Add it to the Project Group.

 

Select New Items→Mulch-Device Application .

 

Select Android target platform.

Place TButton, TMemo, TNotificationCenter in the form.

Add Android service.

Right-click the Android target device.

 

Add Android Service Dialog comes out.

Select automatic.

Specify a directory of service project that you saved.

 

Make sure it is correct.

 

[Create a button click event]

[crayon-67402b3345dcf518470766/]

[Create NotificationCenter1 receive events.]

Write the code in OnReceiveLocalNotification.

[crayon-67402b3345ddb980796847/]

Do you want to build an Android app using C++? Try the Windows C IDE, which will assist you in developing apps in the Delphi or C++ environments.


 

[Execution]

Tap Button1 to start Android Service(“p1”).

Write TNotification received from Service to Memo1→Lines

Exit mobile version