Android :: Application-wide Resources / How To Achieve?
Sep 17, 2010
So I'm struggling a bit with what is probably a fairly basic concept.. Activity Lifecycle.I have read a bunch of thread on the topic, and I feel I understand well both the functionality, and rationale behind the lifecycle model implemented for Activities, but it raises a bit of a problem for me. My app (game) has a couple of distinct Activities for various sections:
1. The TitleActivity is a very small Activity that just launches a GLSurfaceView and renders a startup logo.I use this to detect the OpenGL capabilities of the device (eg so I know if it's using a software renderer)
2. The LaunchActivity is the main menu screen where the user can access options etc and start a game
3. The GameActivity will either launches a GLSurfaceView or a standard View depending on hardware capabilties.
The issue I am having is that I want to pre-load some "slow-to-load" resources, specifically audio, in the Title Activity so when the Launch Activity renders I can play some background music.I have the concept of a "media library" which I use throughout the game.Because of memory limitations in the SoundPool, I have limited this to only absolute real-time sounds and all others are played using mulitple instances of MediaPlayer.Hence my media library has a bunch of pre-loaded MediaPlayer instances which I access regularly during game play.. so it makes sense to have a centralized access point for all audio.All fine, however the problem is that when I launch one activity from another.. for example the TitleActivity starts the LaunchActivity (via a call to startActivity(Intent...)), the former goes through the onDestroy stage of its lifecycle.Now logically I had assumed that if I allocate a bunch of resources in the onCreate of an Activity, I should clean them up in the onDestroy, however in the case of my "media library" if I load up the audio files in the onCreate of my TitleActivity they will be torn down when the LaunchActivity is started because the TitleActivity will have its onDestroy() method called.
View 9 Replies
Feb 22, 2010
I have created several files in a res/values/styles.xml file.
Here's one of them:
CODE:..............
I can apply the style to a single element in the xml by setting the style element like this:
CODE:.................
So, that works, and I notice that change. But what I really want to do is use the style above to apply to my entire application. I thought I'd be able to use this line:
this.getApplicationContext().setTheme(R.style.BlueOnWhite);
Before the super.onCreate of the first activity. But it doesn't work. Should it?
View 6 Replies
View Related
Mar 7, 2010
I want to apply theme over setting application wide. So I implemented below code but there was no effect.
1. AndroidMenifest.xml
<application android:label="@string/settings_label" android:icon="@drawable/ic_launcher_settings" android:theme="@android:style/Widget.ListView" android:taskAffinity=""> -> added Widget.ListView style provided in android system and I changed style.xml file like below
2. FrameWork/base/core/res/res/values/styles.xml
before change : <item name="android:listSelector">@android:drawable/ list_selector_background</item>
After change: <style name="Widget.ListView" parent="Widget.AbsListView"> <item.................................
View 2 Replies
View Related
Jun 28, 2010
I have a theme in my app that defines a custom color for the background. This is the green you see above the tabwidget. In some of my Activities I'm using a Tabhost for my Layout. Now I get something like this as a result: My tabwidget has a black background and I'm happy with that, but the icons in the tabwidget are transparent and this leads to them showing the green background defined in my style. How can I define the tabhost as not styled and have the transparent icons show the tabwidget the resion on instead of a solid background color?
View 2 Replies
View Related
Sep 5, 2010
I'd like to receive a TouchEvent in my Android application any time the screen is touched. Even if my application is not in focus.Is there an general even listener or intent filter I can write to achieve this? The goal is to write system wide gesture engine. So for example, if the user swiped up and then down, a certain application would be launched regardless of where the user is.
View 2 Replies
View Related
Jan 28, 2009
I have created a subclass of Activity, 'CustomActivity', that overrides the onCreateOptionsMenu and onOptionsItemSelected methods. In a couple of other applications I have extended this subclass to provider a common menu for each activity. Is it still possible to access the resources from this Subclass? By default it uses the resources from the current activity (Strings, xml layout etc.).
View 7 Replies
View Related
Feb 1, 2010
How does one go about listing the resources that are available in an application?
For example, I would want to find the names of all files under /res/ xml.
Reflection on the R class didn't seem to work since the identifiers are static constants. R.xml.class.getDeclaredFields() doesn't return any fields.
The AssetManager didn't seem to work either because these are not raw assets.
Does anyone have ideas or examples?
View 4 Replies
View Related
Aug 10, 2010
I have big files to integrate into my application (videos), and thus for not not that my application occupies all the internal memory of the telephones, I saw that it was possible with Froyo to install the applications on the SD card.
I thus have to test this solution and my application settles down well on the SD card, the only problem it is that the system installs all the same my files videos (which are placed in the file /raw) on the internal memory of the telephone. Thus my question it is where to place my videos or where to make so that these also settle down on the SD carde ?
View 2 Replies
View Related
Jul 3, 2009
I created an application which is displaying camera preview. When the application terminates I noticed that some processes are still running. Also if I try to run the original camera application it displays an error (obviously due to the active process which belongs to the custom application).
Does anyone know how to release all resources when application ends?
View 5 Replies
View Related
Jul 1, 2009
I created an application which uses camera and during the appplication execution the screen is always on.
In the onCreate() method I added the lock code...
But after the application termination the screen remains on all the time and if I run the camera application it encounters an error which obviously appears because the camera resources are not released.
Does anyone know how to release all resources on application termination?
View 6 Replies
View Related
Feb 24, 2010
The code I am trying to implement includes a service and an application. When the application is first launched, it starts the service using the
startService(svc_name) call. Here svc name is an intent pointing to the class that runs the service.
I want to share a resource(file/socket connection) between the service and the application. For example one writes to a file and another reads from it. I am unable to get proper sync between the service and app. Could you please let me know how this can be achieved?
View 3 Replies
View Related
Mar 9, 2010
The Android documentation says that best practices are to make two drawable directories - one for HDPI and one for MDPI. It also says that if the MDPI directory doesn't exist and a MDPI device is running the app, it will scale down the HDPI ones so everything looks good. Is there any reason not to just make one high resolution set of graphics? One con that I can think of is performance issues and one pro I can think of is only having one set of images for your app.
View 1 Replies
View Related
Jul 11, 2010
In my Android project, I want to loop through the entire collection of Drawable resources. Normally, you can only retrieve a specific resource via its ID using something like:
InputStream is = Resources.getSystem().openRawResource(resourceId)
However, I want to get all Drawable resources where I won't know their ID's beforehand. Is there a collection I can loop through or perhaps a way to get the list of resource ID's given the resources in my project?
Or, is there a way for me in Java to extract all property values from the R.drawable static class?
View 4 Replies
View Related
Jul 11, 2010
Is it possible to do polling in Android? For example, I want my application to monitor a directory continuously. If there is for example a new folder created in that directory I want to log it down. Is it possible to acheive this by polling? Or is there any other way to do this?
View 7 Replies
View Related
Jul 11, 2010
I've been using the HTC IME keyboard for a while
but i want to try something different
does anyone know of a keyboard application with wide keyboards?
View 1 Replies
View Related
Jun 24, 2009
I have a webview and need to trigger a function when a user clicks on particular url. How can I achieve this?
View 5 Replies
View Related
Oct 17, 2009
I am pondering the alternatives on how to scroll an "infinite", scale-like, control in android. The simple idea is to redraw the entire view on each scroll movement, but somehow it doesn't seem like the proper way. It is possible to draw the contents before-hand, but I have no clue how wide I should make the view in the first place, and what happens when the user scrolls to the end of the view? I guess I need to extend the view towards that direction. Should I go towards programatically adding (and removing) chunks of view to a linear layout? It would be great to hear what experiences are out there regarding drawing this kind of long-scrolling custom control.
View 2 Replies
View Related
Jun 4, 2010
I am trying to add a listener to my service that listens for volume key presses. I would like to act on presses even if my service is not in focus. Any idea how to do this? I have looked over the API, as well as performed google searches.
View 4 Replies
View Related
Mar 25, 2010
I am working on an app that uses webview for a help section.The help section is loaded from an external site, that is specifically designed for mobile phones.There are a series of 5 pages, with a simple next/ back navigation.When the first page loads, it loads perfectly, filling the entire area of the screen.When you click next, the page is now smaller with a large white gap around it (right and bottom), when I click back to the first page, this page now is displaying the same way (gap around it).I have tried setting body/table/container divs to 100% wide, and this continues to happen.However it works perfectly on any desktop browser.
View 4 Replies
View Related
Aug 22, 2010
I'd like to populate a listview from 2 tables. Anyone know how I can achieve this? Currently what I have looks like but it only works with one adapter.
View 1 Replies
View Related
Oct 26, 2009
I am developing an application in which a user keeps on scrolling and each view displays a single text. The views are not suppose to end. How can i achieve that?
View 4 Replies
View Related
May 28, 2009
I want to make my android project Internationalization,but i don't know how to achieve it. I have searched on the internet,and just know i have to make values-xx file in
es.I want to know what should i do about the code.
View 2 Replies
View Related
Oct 8, 2010
I am trying to develop small application for reset Logging on Phone. Can some one throw some Lights on how to achieve logging in AndriodRunTimeInit whenever there is exception? I want to write into file whenever there is RunTime exception.
View 1 Replies
View Related
Jul 15, 2009
Is there any way to achieve perspective drawing of an image.. are there any APIs.. or is OpenGL the only solution..
View 2 Replies
View Related
Apr 19, 2010
Things go fine, and i am able to design a layout like this...
View 3 Replies
View Related
Feb 1, 2010
I am drawing a pretty simple scene, with one large texture the about size of the screen (two triangles). I notice that the frame-rate is irregular: in most of cases, a frame finishes in 17 ms. However, in about 1 of 10 times, the frame finishes in 33ms.
My guess is probably some background services need to run. However, the Linux scheduler is biased towards my FG app, so the BG services are usually starved, until they can't take it anymore and they grab the CPU from my app ....
I am seeing stuttering in the animation. Is this due to the irregular frame rate? Should I delay each frame so that all frames are rendered with 33ms frame time? If so, what's the best technique of achieving this?
Is there an API that I can call to guarantee CPU resources for the render thread .... I really hope Android runs on some sort of real time kernel ...
View 7 Replies
View Related
Jul 5, 2010
On iPhone, Mobile Safari is WebKit based and supports hardware-accelerated -webkit-transform CSS properties. To be specific, I use the translate3d() transform.
What alternative is there for the Android browser? I need it to work on Android 1.5.
View 1 Replies
View Related
Oct 30, 2010
I would like to have a layout with 5 times 5 buttons. Each of them should have the same width and height (they should be square). And I want the whole matrix to use the screen width (or height, depending on rotation).
I currently do it "by hand" in the Java code:
CODE:...........
This can be improved by obtaining screen width first and then dividing by 5 to get rid of this literal 60. But I'm wondering how I can do this in the res/layout XML file? How can I specify for the height to be the same as the width? (I can set the width to match_parent.)
View 4 Replies
View Related
Mar 24, 2010
When i use toast to display some text on screen it displays little bit above the bottom(default position).
now i want to display it in the middle of screen or according to my choice can any one guide me how to achieve this?
View 1 Replies
View Related
Jan 30, 2009
When using a mediaplayer to play back an audio file, you can set looping to true - that's not the issue here.
If looping is set to true, there's still an audible gap between the file finishing and then starting again.
How could I achieve true gapless playback? I've attempted using two instances of the same file, overriding oncomplete and onseek.. can't seem to improve the gap though.
View 6 Replies
View Related