Skip to main content
This topic has been closed for replies.

8 replies

Participant
July 12, 2012

What about the case where you are in an Android service (such as one that picks up push notifications)? In this case, Android will instantiate your service directly, without invoking AIR. So there will be no FreContext available. Yet I still want access to a resource (such as a notification icon to pass to the Android notification manager when I tell it to post a notification to the status bar).

How would I get the correct icon without having a FreContext? Or, alternatively, how can I get a FreContext that's capable of getting a resource ID, when I'm within the context of an Android service that's been started via a Google-initiated Intent (AIR runtime not running)?

marchbold
Inspiring
August 1, 2012

Hey,

It's fairly simple, once you find out how to search the resource tree. We wrote some code to do it which I've just put up here: http://labs.distriqt.com/post/1245

Once you grab the class there you should be able to access the application resources wherever your code is executed:

int iconId = Resources.getResourceIdByName( context.getPackageName(), "drawable", "icon" );

Cheers,

Michael

air native extensions // https://airnativeextensions.com
Participant
August 27, 2012

Michael,

Now that I have the resourceId from the ane, how do I get a flex mobile application to find the resource?

For example, I try to get a string resource with the following statement:

String myStringRes = mContext.getString(Resources.getResourseIdByName("mypackage", "string", "extension_name"));

mContext is the Flex application context.

This call throws a ResourceNotFoundException.

Any thoughts on this?

Thanks,

Stephanie