结合JAVA和AIR codeS的Andr​​oid应用 [英] Combining JAVA and AIR codes for Android app

查看:146
本文介绍了结合JAVA和AIR codeS的Andr​​oid应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何能结合JAVA code和AIR codeS在Android的一个应用程序开发 这里有一个例子, <一href="http://rosarioconti.word$p$pss.com/2010/10/03/extending-your-android-air-application-using-java/" rel="nofollow">http://rosarioconti.word$p$pss.com/2010/10/03/extending-your-android-air-application-using-java/ 但将它的工作???我需要调用一些空气codeS在我的Andr​​oid应用程序?
编辑
我需要这个code在空气中被从Java称作是这可能吗? HTTP:/ /coenraets.org/blog/2010/07/video-chat-for-android-in-30-lines-of-$c$c/ 或者基本上我需要的是这样一种服务,这是可能的JAVA?

How can we combine JAVA code and AIR codes for an app development in android here is an example, http://rosarioconti.wordpress.com/2010/10/03/extending-your-android-air-application-using-java/ but will it work???i need to call some air codes in my android app??
EDIT
i need this code in the AIR to be called from JAVA is it possible? http://coenraets.org/blog/2010/07/video-chat-for-android-in-30-lines-of-code/ or basically i need is a service like this,is this possible in JAVA?

推荐答案

Adob​​e AIR中必须使用的Java客户端上没有原生的方式。

Adobe AIR has no native way to use Java on the client.

不过,你可以尝试 http://www.merapiproject.net/index.php

默拉皮充当中间人,通过AIR和Java之间的对象。

Merapi acts as a "middle man", passing objects between AIR and Java.

在code是这样的:

从ActionScript 发送消息:

var message : Message = new Message();

message.data = "Hello from Merapi Flex.";

message.type = "Reply";

Bridge.instance.sendMessage( message );

从Java 发送消息:

Bridge bridge = Bridge.getInstance();

Message message = new Message();

message.setData("Hello from Merapi Java.");

bridge.sendMessage(message);

接收消息的软硬度:

<merapi:BridgeInstance

id="bridge" result="handleResult(event)" />



<mx:Script>

<![CDATA[

private function handleResult( event : ResultEvent ) : void

{

var message : IMessage = event.result as IMessage;

接收消息在Java中:

Bridge.getInstance().registerMessageHandler("Reply", messageHandlerInstance );

public void handleMessage( IMessage message )

{

System.out.println( message.getData() );

}

注意:

虽然不是我测试 - 可以添加自定义的Java类到Android。只需确保自定义类是公共的,有一个公共的零参数的构造函数,并构造链父类的构造。

While not tested by me - one can add a custom Java class to Android. Just make sure that the custom class is public, has a public zero-argument constructor, and that the constructor chains to the superclass constructor.

具有code的默拉皮火山(它是开源的)会给你自定义它为Android的能力。

Having the code for Merapi (it's open source) will give you the ability to customize it for Android.

您可以将该类添加到你的Andr​​oid的Java code和汇编,就像任何其他Android应用程序。在AIR code将是一个单独的应用程序。可能有一些安全问题,以克服在两者之间进行通信。

You can add the class to your Android Java Code and compile just like any other Android application. The AIR code will have to be a separate application. There may be some security issues to overcome to communicate between the two.

这是一个潜在的选择,但可能无法正常工作。最好的方法是编写一个测试应用程序,看看你能得到它的工作。然后问其他问题需要的。

This is one potential option but may not work. The best way is to write a test application and see if you can get it working. Then ask other questions as needed.

这篇关于结合JAVA和AIR codeS的Andr​​oid应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆