Skip to main content
Participating Frequently
October 18, 2011
Question

How to access android resource in java native extension....??

  • October 18, 2011
  • 4 replies
  • 3576 views

hi..

i want access android resource..

for example, res/menu/menu.xml, res/values/strings.xml ... etc...

- R.java -

/* AUTO-GENERATED FILE.  DO NOT MODIFY.

*

* This class was automatically generated by the

* aapt tool from the resource data it found.  It

* should not be modified by hand.

*/

package com.flash.extension.nativelib;

public final class R {

    public static final class attr {

    }

    public static final class drawable {

        public static final int icon=0x7f020000;

        public static final int notification_icon=0x7f020001;

    }

    public static final class layout {

        public static final int main=0x7f030000;

    }

    public static final class string {

        public static final int extension_app_name=0x7f040001;    -> "hi extension"

        public static final int extension_hello=0x7f040000;

    }

}

so i used getResourceId("string.extension_app_name");

but it's not work.. throw NotFoundException error..

so i used context.getString(R.string.extension_app_name);

it's work, but return incorrect value.. -> return value is "0.0.0".. it's versionName in actionScript Client Project..

why can't access android resource in native extension?

how to get android resource in java natvie extension..??

Is there anyone who has a sample source??

help.. me.. please..

This topic has been closed for replies.

4 replies

Participating Frequently
October 19, 2011

Hi,

Based on my investigation, you need to copy res directory in android project to <ANE source>/Android-ARM before packaging ANE. Please read "Android details" section in this article for details: http://fireworksmx.de/devnet/air/articles/extending-air.html

Let me know if this issue still occurs.

Thanks,

Jian

Adobe Flash Runtime team

cbigbAuthor
Participating Frequently
October 19, 2011

Thanks a lot, zjian..

I succeeded get resource.. (string, icon.etc)

but i can't get resource menu.

- code -

int menuId = getResourceId("menu.mymenu");

Log.i("AIRExtension", "[NativeMenu.show()] menuId=" + menuId);

activity.getMenuInflater().inflate(menuId, menu);

it thorw exception..

is it impossible that create opition menu manually by menu resource ??

Participating Frequently
October 24, 2011

Hi,

It is expected that the code you mentioned doesn't work. Please email me (zjian at adobe.com) and I will give you an example I got from one internal engineeer.

Thanks,

Jian

Adobe Flash Runtime team