This is a basic template for AirApps.
The template will help you extending basic flash apps by adding a context menu with 2 extra functionality ( DialogBox and Exit Button) on top of air.
Basically what you have to do to run this example it’s installing Eclipse and and the adt plugin for android, if you don’t have it already installed.
I decide to add this article because I’m starting seeing many apps running in background even if the window is not focused.
Someone said it was not possible to kill the app on exit…
I said let me try and see what can we do.
Please leave a comment.
The Structure:
(Resources used app.xml and test.swf)
The Swf loaded with the context Menu…and
the EXIT BUTTON!
Enjoy! The source is attached here.
(rename the extension from odt to zip)
Tags: air, android, Conti, dex, extend, flash, flex, java, Rosario, template, wrapper
December 17, 2010 at 9:09 pm |
Really good one, I will try !
December 18, 2010 at 2:35 am |
Thanks,
I try to hack whatever I can 🙂
February 9, 2011 at 4:48 pm |
Hey there
Thanks for the post!
Was wondering if it was possible to create a service on Android using this approach, and then having that service start up when the device boots.
It would only launch the SWF (AIR) app when the application is active.
I wanted to attempt this because from what I understand, you can’t create a service to run on Android with AIR, and I am hoping this might be a way to get around that?
Thanks
February 9, 2011 at 8:32 pm |
Hi Teshin,
the response is YES you can and I found also the example who did this service already which you can use to extend in my app.
http://www.androidcompetencycenter.com/2009/06/start-service-at-boot/
Let me know whe you done, I want to see it 🙂
March 17, 2011 at 6:51 pm |
[…] app to allow AIR access unavailable APIs | Deep Dive Into Flash Ein anderer Ansatz ist das hier: Extending your Android Air Application using Java Rosario Conti __________________ mfg […]
April 12, 2011 at 12:51 pm |
Brilliant work, thanks so much for putting this online! One thing I’ve noticed is that the built applications don’t detect whether AIR is installed and take to you its app page if not – do you have any suggestions for how this could be added to an application, e.g. using .smali files from an APK produced by ADT?
Thanks & all best!
April 12, 2011 at 2:17 pm |
Nessuna problema :).
Detecting if AIR is installed is more simple of what you think. Just make a check to see if the directory/package “com.adobe.air” exist if so…you can execute your app.
I don’t think it was relevant at this point to put that check in here but you can add that 🙂 , this is just a very simple example.
Enjoy.
September 15, 2011 at 9:32 am |
HI,
I am able to run the hello world application.I have one question correct me if I am wrong.Here the android framework is launching the code written in flex from the file –> app.swf right?? Which has the code of hello World inside it.Now suppose if I want to run another .swf file being created from the Flex what changes and and which files I have to change to make it run similairly like hello world app in eclipse(inside android).I did try it by replacing the app.swf with the myflexapp.swf and app with the myflexapp word in the application.xml file but it doesn’t work.Any way to make this run.Also I need to pass the variables/data to this flex code and finally run it and then come back to the android code(activity).Plz assist or direct me to the useful pointers which could solve my problem.
Zillion Thanks in advance
Best Rgds,
Saurabh
September 15, 2011 at 6:37 pm |
hi Saurabh,
make sure when you add you own file to have the same filename inside the XML otherwise ti will never load because it cannot find it.
The quick change you can do is to rename your swf to app.swf or whatever I called the swf (I don’t rememebr right now exactly).
It is important to pass th right values to AIR otherwise it will never run.
Another tip is if you do this change and it is still not loading or loading and nothing appears , remove the RSL digest from you app.
Btw the best you can do to me to understand what r u doing wrong os to pass me the ADB logcat.
Ciao!
September 18, 2011 at 3:23 am |
Hi Rosario,
I managed to get the swf displayed but the buttons were somehow missing. Do you mind to give me some hints what might go wrong?
Grazie!
September 18, 2011 at 6:57 am |
somehow ? 😀
well the only 2 things you should check if you MODIFIED something… which I guess so… it is
the option menu item in the java code and inside the manifest the “theme” used which COULD interfere with the screen.
If you didn’t change anything then… tell me on what device are you testing and if you can add the log cat.
non c’e’ di che! 😉
Rosario
September 18, 2011 at 8:45 am
Hi Rosario, thanks for the quick response. I tried many different virtual machines from 2.1 to 2.3. Then the swf finally came up on 2.2 and 2.3 after I installed AIR runtime onto the virtual machines. Actually, I even tried it on a real Sensation but only the swf was displayed. Do you mind to give me your email since the log is a bit long.
September 23, 2011 at 11:11 am |
Hi Rosario
Thanks for this , i am able to run it now.I have a question is it possible to pass the arguments to .swf file via android or java code example – hello .I want the input to be done from the other programming language side like (java and android))
Rgds,
Saurabh
September 23, 2011 at 6:24 pm |
Yes you can, from anywhere you want .
From java you can actually pass the value by adb then the java app read the values passed then you need to set those values to the air args “-nodebug ” + …the argumetns passed by adb.
In flash you simply use the way you always did to read arguments.
If you want the code you need to wait because I’m kind busy right now but I already have done this.
September 28, 2011 at 10:33 pm |
From Java to get the arguments use to send:
adb shell am start
-a android.intent.action.MAIN
-n com.what.EVERISTHENAMEOFYOURAPP/.YOURAPPNAME
-d ACODETOFILTER
–es args param1##00param2
final Intent intent = this.getIntent();
Uri mUri = intent.getData();
Object strs[] = new Object[2];
String convStr =” “;
if (mUri != null) {
String uri = mUri.toString().trim().toLowerCase();
Log.d(“[extra_args_uri]”,”” + uri );
if (uri.contentEquals(“ACODETOFILTER“)){
Bundle bundle = intent.getExtras();
String _args = bundle.getString(“args“);
//bundle.size()
if (_args != null){
String[] __args = _args.split(“##00″);
int c=0;
convStr = ” — “;
while (c < __args.length) {
convStr += getString(R.string.amp) + __args[c] ;
Log.d("[extra_args args]","["+c + "] = " + __args[c]);
c++;
}
strs[0] = convStr;
strs[1] = __args;
} else {
Log.d("[Arguments Info 2]","You must specify arguments. No arguments found.");
}
} else {
Log.d("[Arguments Info 1]","You must specify: -d ACODETOFILTER in order to activate the arguments.");
}
} else {
Log.d("[Arguments Info 0]","No arguments found.");
}
return strs;
}
in the air instantiatio use:
String args[] = {lAppXmlPath, lAppRootDir , lAppExtraArgsDefault + " " + lAppExtraArgs….
Then try to use an intent to filter calls:
final Intent intent = this.getIntent();
final String action = intent.getAction();
// For an edit action:
if (Intent.ACTION_MAIN.equals(action)) {
uf.setVar( "myargs", getString(R.string.extraargs));
} else if (Intent.ACTION_INSERT.equals(action)){
// For an insert or paste action:
Object[] args = (Object[]) getArguments();
String inlineStr = ((String) args[0]);
String[] arrayStr = ((String[]) args[1]);
lEditor.putString("myargs", "" + inlineStr);
lEditor.commit();
reboot(); your reboot function
}
in FLash:
NativeApplication.nativeApplication.addEventListener ( InvokeEvent.INVOKE , handleArgs );
private function handleArgs ( event : InvokeEvent ) : void
{
_urlArgs = "?" + ( ( event.arguments[0] != undefined ) ? event.arguments[0] : "" );
addEventListener( Event.ADDED_TO_STAGE , addToStage );
}
ENJOY
December 23, 2012 at 3:26 pm |
I’m really enjoying the design and layout of your website. It’s a very
easy on the eyes which makes it much more enjoyable for me to come here and
visit more often. Did you hire out a developer to create
your theme? Excellent work!
November 26, 2014 at 7:54 am |
Hi
i am so happy to finally see a article that is about how to call flash in native android application, i downloaded your example code and try it on my emulator, got this error message from logcat, please help me out, thanks in advance
11-26 07:51:25.588: I/[Dex Loader](562): Error in loading dex and creating activity wrapper- android.content.pm.PackageManager$NameNotFoundException: Application package com.adobe.air not found
11-26 07:51:25.588: I/ERROR(562): Error in launching AIR appjava.lang.NullPointerException
December 1, 2014 at 12:44 am |
If you read the comment u will see he is trying to load com.adobe.air …. now is that the package you want to call ? I don’t think so.
April 23, 2015 at 12:52 am |
so greate!!!!! thank you