Sorry for my bad english.
I want to make a game for Android platform, but every time when i change my device orientation, the activity is restarted and i loss all data. I had read that i can prevent activity from being restarted by overriding onConfigurationChanged function in Android. The problem is that i make my game in Flash, with AS3 and i don't have access to Android API, therefore i must create an ANE which will handle onConfigurationChanged, but this doesn't work and i don't know why...onConfigurationChanged is not triggered when i change my orientation.
Question is - Is this possible to handle onConfigurationChanged from an ANE?
I work in FlashBuilder for Flash, and Eclipse for Java to make ANE, and there is 2 manifest files in which i can put android:configChanges="orientation|screenSize", one in Flash Builder and one in Eclipse, which of it must contain android:configChanges="orientation|screenSize" ?
I'm novice in android and ANE's and my be i do something wrong.
Are you simply trying to handle the orientation changes? You shouldn't need an ANE for this, have a look at the autoOrients and ORIENTATION_CHANGE event:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/StageOrientationEvent.html#ORIENTATION_CHANGE
If your application is restarting it's most likely something slightly amiss in your application descriptor. Just double check that you've got all the defaults in the manifest additions under the android node.
Related
I'm developing an app. I have implemented dark mode by creating colors-night file , using a switch and appCompatDelegate. I have written some code so that the app doesn't follow the system when phone's dark mode is on . And it works properly. Yet, the Splash screen does not obey and appears dark-colored when phone's dark mode is on(while the app continues light). I know this happens because the system reads the night resources before launching. (I figured it out since disabling dark mode in the onCreate method in SpashActivity or in Application does not work(and did some research) ). Adding "forceDark = false" on xmls doesnt work either. Does anyone know how to fix this?
I know it would be better to leave it this way since it is user's preference but i want on the first use, the user to see my company's colors and logo and then, choose the dark theme. Which, i also cant find how to change. I mean change dynamically splash activity's color depending on the sharedPreferences. (as i said before, doesnt work).
Thank you in advance :slight_smile:
I've been working on an app, and it's came long great. I have a problem though, Android, being greedy with its resources, loves to kill the app when I put it in the background. This is very bad, because the app is actually intended to be an AI assistant, and having to reinitialize every-time I need to use it means that it's not going to be very helpful in a real work environment.
I investigated ways to prevent reinitialization of the AI's brain, however, none of the methods have been very fruitful. Saving the instance of its brain will not work, because the POS models that she needs to operate can't be serialized. And employing a service won't work either, because if I want to communicate with the activity via the service, I have to reinitialize it along with the activity (correct me if there is a way around this, I just notice most tutorials put service.start() in the onCreate methods)
Is there a way around this? I only need to preserve the POS models. They take a while to load in for some reason despite only being a few megabytes.
Please note that this is to prevent data from being killed. There are no background processes that need to be ran.
You need to set a Notification to tell Android not to release your resources.
See this question: How can we prevent a Service from being killed by OS? . While the question itself is not directly applicable the answers have a lot of overlap with this issue.
You should probably be using a Service if you want to run things in the background though as Activities are only supposed to run when you have a layout in the foreground. You could store your required object in the service, grab it as necessary when (re)starting an Activity that requires it and update it when your Activity loses focus.
Edit: I accidentally pasted the wrong link. Now corrected.
Also, have a look at this Android resource if you have not already: http://developer.android.com/training/basics/activity-lifecycle/recreating.html
I need to develop a tweak that let me use some gestures in every part of the system so they must be valid in the launcher and in every app that I launch.
I think that I must override the basic android recognize touch system... and re-write part of them.
Wich are the method responsable of what I want?
Can someone post me one example of how do that?
I saw that some custom launcher (like the LG phones) use them.
Is it at all possible to create an App Widget programmatically from within an Android app itself? I'm rather lost on how to do this and Googling so far has led me to believe that it is not possible (that an App Widget and an App itself has to be separate applications).
So, would it be possible to dynamically create an App Widget from within an Android App? If not possible, how would you approach it? Thanks all!
Is it at all possible to create an App Widget programmatically from within an Android app itself?
That would depend completely upon what you mean by this.
I'm rather lost on how to do this and Googling so far has led me to believe that it is not possible (that an App Widget and an App itself has to be separate applications).
No, an app widget most certainly can go in the same Android project as the rest of the application. In fact, usually it does.
So, would it be possible to dynamically create an App Widget from within an Android App?
Again, you seem to think that the world knows what you mean by "dynamically", forcing us to guess.
An app widget, from the standpoint of code, consists of an AppWidgetProvider, an entry in the manifest pointing to that AppWidgetProvider, a metadata XML file, and whatever other resources you need (layouts, drawables, etc). All of that has to be written by a programmer and included in the app at compile time -- you cannot "dynamically" create those things.
An instance of an app widget is put on the home screen by the user, not by the programmer. Hence, a programmer cannot "dynamically" create instances of an app widget.
What the programmer can do "dynamically" is decide what is displayed inside of the app widget (e.g., current headlines for a news ticker, current song being played for a music player).
I'm working on a game which would work both on the web, as an applet, and on the Android phone, as an app.
Is that possible to do, and if so, what do I need to be aware of to make that work (i.e if there are any settings that I shouldn't hard code and instead determine them based on the user's device when the game is run, or any java libraries that I shouldn't use?).
Also, the game needs to accept touchscreen as input for the Android app. Is that possible to build into the same game which will also be run as an applet? May be so at run time, the applet decides whether to use Mouse or Touchscreen for the input when it is run?
Although Android apps are written in Java, the framework around the app is extremely different of the framework wrapped around an applet. You won't be able to have one .jar file that you can include as an applet and throw at an Android device because that's just not how it works.
You will however probably be able to create all the game logic and objects and have them in be shared with the applet code and android app. You can probably even get away with having them in one repository and project (although it's probably going to have to be an Android project that you then wedge in your app build scripts).
In order to tackle the different controls for your game you are probably going to have to abstract away the input, and have your game/level object have a call back like userHasPoked(int x, int y) and then have the applet call that method on click of the mouse and the android app calls it on touch (which is oddly still called onClick).
I think it'll be a long road, but much easier than rewriting the whole thing. It'll probably seem like a lot more work up front, but once you are done wedging your code into an applet and an Android app, you'll probably "never" have to touch that code again and can just keep adding to the game.
I wouldn't underestimate the task, but that sounds like a very fun programming exercise. Good luck!
What kind of game do you develop? It may be the better approach to develop an Javascript game.
That can be installed with phonegap (cordova) onto an android device.
Let me break this for you....
Model - The Business Logic and Data
View - The Display of the Output of the Model
Controller - On which the action is done.
The advantage of using this MVC architecture is that, you can keep the same model and keep changing the Views.
So keeping this idea in mind, you can have the same model for both the Web App and the Android App, and then implement each others Views to it respectively.