Problem in Android Game using AndEngine - android

Hey all,
I am having an unusual problem with my Game. I am loading six textures in my Game, the initial one is a type of Game Background. Now at click of a Sprite i load a Dialog with infalted XML. The problem occurs here, when it first loads my game Background becomes black, when it reloads again it returns to it's original, when it reloads again it's black and it continues like this. It's a big code and that's why i cannot post it here, may be any one of you help me in this. I am stuck since many days in this, I have not unloaded any Texture, but still it's looking like that...............
Hope to get some help from you all..................
Thanks............

Try copying your game to another project and keep removing stuff to narrow down the problem until you don't have the problem anymore. I'd start with removing textures.
How many textures of what size do you have?

This is my raw guess.
you could have kept the Dialog's inflated xml root layer's(linearlayout) height and width as fill_parent. This could have occupied the entire screen and let things black.
make it as wrap_content to both.

1024x600 Textures are impossible! Both dimensions have to be a power of two, AndEngine does not accept other dimensions as many (all?) devices would not allow this.
Sorry but my time is currently very limited (due to exams =( ).

kkkkk SO it's a very delayed answer but still, may be it may help others. I exactly don't know what the problem was but after removing a texture, making size of some other's small, and also when android got updated, the problem is now very delayed, or it rarely comes.
So as per what i can think there seems only two issues, some memory prob or some bug in android which resolved with new update.

Related

Setting view alpha in runtime is slow, how to speed it up?

I have two ImageViews which I hope imageViewA is overlapped by imageViewB, and when user select a seekbar, the alpha value of imageViewB will change accordingly (e.g., becoming translucent and users can see part of imageViewA).
It supposes to be a easy coding task, however I found the performance is VERY slow in my Galaxy S6.
I have tried all setAlpha(int), setAlpha(float), and setImageAlpha(float), but get no hope. It seems the most related question post is App UI operations (setting alpha, setting margins, etc.) very slow on 4.4.4 compared to 4.0.3
However, this question is still open. Does anyone knows how to speed it up?
---- Here is some updates ----
The minimal code is just simple, in the seekbar callback I made
imageViewB.setAlpha(selectedAlphaValue);
The VERY slow means the fps is less than 1~2. I do hope I can get the alpha changed 10 times a second to make users feel comfortable. (BTW, I don't benchmark the delay of set alpha function because it is TOO SLOW, even my human eyes can notice it only changes 1~2 times per second)
Thanks Nikola,
ViewCompat.setLayerType(view, LAYER_TYPE_HARDWARE, null)
Is the right thing to do. It solve my problem like a charm.
Could you please post your reply as an answer, Nikola? So I can rate you as the correct answer.

Creating a more responsive android notification

I am interested in what the current best practice for android API 16 is when it comes to changing a notification button.
Currently I set the bigContentView and use setOnClickPendingIntent() to make callbacks to the service but I'm finding the notification to be really slow at being updated as it has to change one of the button images between two different states (like toggling play/pause).
After logging ive traced it down to the code of swapping the drawable button.
setImageViewResource(viewId, srcId);
Takes anywhere from 1.0s - 0.3s which is a noticable delay for the user, surely there must be a better way? Or something I'm blatantly missing?
Any suggestions to avoid the update delay or any feedback on my current implementation would be greatly appreciated.
Load the two ImageViews above each other and switch the visibility between them. This way you will only need to load them once and you will avoid many Garbage Collection calls that could result in slow responsiveness in your app and you can also scale down your resources to a smaller size.

Avoid high overdraw and long View drawing

I have a problem with a BI application I'm writing.
The application uses AChartEngine for charts and most of the table data is inflated programmatically. There are currently two main problems I'm facing:
When the application switches orientation, it takes around 8-10 seconds to redraw every dashboard element (i.e. to display data). Is this a problem with overdraw or something else (this happens on N4, N5, Note 3...). This is unacceptable and I really need to fix this!
There's almost 4x overdraw on table row elements, and I managed to get it lower - to around 2-2.5x with getWindow().setBackgroundDrawable(null). How do I fix this much overdraw as everything is inflated from code? (here's an example of how it looks like: http://prntscr.com/2lio5q).
Regarding overdraw:
Have you checked Romain Guy's Android Performance Case Study:
http://www.curious-creature.org/docs/android-performance-case-study-1.html
You can also find several Google I_O Videos by him (some of them dated) that might be helpful.
I finally fixed the orientation working very slowly. I applied few flags to my FragmentActivity in the manifset and it works much better now, flags are android:configChanges="screenSize|orientation|keyboardHidden".
Keep in mind that for this kind of thing it is much better and Android-like to use the FragmentPagerAdapter than FragmentActivity, but I work with what I got.
Hope this helps someone!

Android - How would i go about using RelativeLayout with background image scale right on different devices

As you can see in the photo I have a scaling problem with my design. Actually there is two problems. One involving a textview and one about scaling. I found out that the easiest solution for layout was to implement a background image to my RelativeLayout. (This may be a stupid approach i don't know.)
As you can see in the images, the text changes position on textview.setText("blabla"). And is creating visual problem. How would I go about fixing this?
Secondly, how would I solve the scaling issue on different devices? My initial plan was to make one background for each size. Like mdpi, hdpi and so on.. But how do I tell the app to choose between background? And is this even possible?
Am I doing it all wrong? :)
Positioning problem http://chk.no/bue/stackoverflow.png

How did they make such layout - which elements they used?

At the moment, I am using Euro 2012 app and it has some interesting layout parts. If you go to matches->knockout screen, you'll see 3 screens like this.
If you slide left or right, you move between them not like between one activity to another, but just like all these elements are laid on one big canvas and you slide each screen into focus. Even thou, if you slide left/right, the screen cannot be stopped in the way that half of each image is visible, so I guess it's not a big canvas. Somehow you can slide screen like one big image, and yet it always lock perfectly as if they used 3 activities for this.
How did the do this?
It's a ViewPager, available in Android support package and described in their blog.
The designing is not so much difficult, As i think to draw that boxes showing quarterfinals, semifinals.
They having layout( we can do by placing image in background also).
The major role played by FrameLayout which shows you that effect(emphasis), the flages are fetch from url as matches are decided(not essentially images only names are sufficient as flags came inside app and gets applied as updated).
After your click i think the start image gets change it's just replacing that image with new one.
As you said they are not on single canvas (but if they did customization of heir Viewpager that it's not stopping in between activities), but i think it's on single canvas.
If your taking about quickness of loading and all it's up to you as much code and processing you optimized it gives you smooth feel and fast processing.
We can appreciate the work but we can not say it's too much difficult as i think it's quit easy...
Hope this explanation helps you to understand ....

Categories

Resources