简体   繁体   English

如何在JNI Android导入的类中将事件方法实现为XE5

[英]How to implement event method in JNI Android imported class to XE5

I am interested in implementation of event method in imported interface of JAVA class to Delphi XE5. 我对在JAVA类到Delphi XE5的导入接口中实现事件方法感兴趣。 Example: 例:

Imagine we want to use JBroadcastReceiver from Androidapi.JNI.GraphicsContentViewText. 假设我们要使用Androidapi.JNI.GraphicsContentViewText中的JBroadcastReceiver。 There is a event method: 有一个事件方法:

procedure onReceive(context: JContext; intent: JIntent); cdecl;

Method is fired if a broadcast message is received as far as I know. 据我所知,如果收到广播消息,则会触发该方法。 Do you have any idea how to implement in a my own application? 您知道如何在自己的应用程序中实现吗?

In Java code new class extending BrodcastReceiver class. 在Java代码中,新类扩展了BrodcastReceiver类。 But in XE5 it is not possible. 但是在XE5中是不可能的。 I think. 我认为。 So how to enforce to call my implementation of this method. 那么如何强制调用此方法的实现。 In this method should be some code to do and show a notification for user. 在此方法中,应执行一些代码并向用户显示通知。 I persued it is possible. 我相信这是可能的。 I have found the component but I cant to download it. 我已找到该组件,但无法下载。

http://chuacw.ath.cx/blogs/chuacw/archive/2014/02/26/delphi-ide-broadcastreceiver-plug-in-for-android.aspx http://chuacw.ath.cx/blogs/chuacw/archive/2014/02/26/delphi-ide-broadcastreceiver-plug-in-for-android.aspx

Thanks 谢谢

I will answer by myself. 我会自己回答。

I have found some example which is not absolutely written in Delphi. 我找到了一些不是绝对用Delphi编写的示例。 There is important to write some code in Java, but it is very simple. 用Java编写一些代码很重要,但这很简单。

Look at the: 看着那(这:

http://www.gobookee.org/ebook/auto-start-a-delphi-xe5-android-app-after-boot-danny-wind-7q6nap/ http://www.gobookee.org/ebook/auto-start-a-delphi-xe5-android-app-after-boot-danny-wind-7q6nap/

Android background service in Delphi XE5 Delphi XE5中的Android后台服务

There is an example of BroadcastReceiver and Service also. 也有一个BroadcastReceiver和Service的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM