yashsingh1/xdaforums huggingface dataset:
[Java for Android App Development] Wampirate:
Ok, once I do it I'll post. Do you know something about out of memory error?

Is it because of too many bitmaps? And is it the amount that matters or size or something else? I was getting that, then I created a free memory method (using bitmap.recycle()) and divided game resources into two groups, menu and game, but now I'm again getting that error :D I must do some changes to my bitmaps, combine some of them I think

Edit:

A question: when I have a Bitmap bmp and load an image like this

bmp = BitmapFactory.decodeResource();

and then do something like this:

bmp = Bitmap.createScaledBitmap(bmp, ...);

Do I still have the memory for the original image used?

Maybe I should have another Bitmap, like this:

Bitmap bmp,loader;

loader = BitmapFactory.decodeResource();
bmp = Bitmap.createScaledBitmap(loader...);
if (loader!=null){
loader.recycle();
loader = null;
}
[Java for Android App Development] nikwen:
Out of memory errors can also occur due to other reasons, e.g. creating too many objects. Create as few objects as possible and recycle them if possible (by just changing all values).

---------- Post added at 08:18 PM ---------- Previous post was at 08:10 PM ----------

You load them just when you start your app, right?

I do not think that you load too many or too big bitmaps (even though it might still be possible). Just think of the big 3D games and their tectures. There might be memory you do not free.

Do you save them in Collections (like Lists or Maps)? If you do, remove it when you do not need it anymore.

I don't know whether you need to recycle it in that case. It would make sense though.
[Java for Android App Development] nikwen:
It depends on your objects. The dalvik VM is limited to a certain amount of RAM which is different on every phone. (I think it is defined in the build.prop file.)

I'd suggest doing the text thing as described in the link I gave you. That would need far less RAM.

That means that it cannot get the canvas. It might not be valid if super.onResume() has not been called before. For which code is that logcat? Did you try my code in post #92 of this thread?

I don't know what this callback does but Google should. ;)
[Java for Android App Development] Wampirate:
Doing the text thing would actually make me redo my whole interface ^^ I'd rather stay with what I have for this project, and implement that method in another one :D

It was the logcat from your code exactly, with commented log line, which was also breaking app
[Java for Android App Development] nikwen:
Ok, that means that it cannot get the Canvas.

One question: Have you used Google?

That is what I found:

http://stackoverflow.com/questions/10277694/resume-to-surfaceview-shows-black-screen

That would mean that you will not need more code. So remove my code from onResume and onPause and add those methods. Let's see whether it will work.
[Java for Android App Development] Wampirate:
I did use google but I didnt find this one, he has it very similar to mine. But I have tried resuming and pausing again if that's what you're telling me to do and it didn't work, I even tried making a boolean in gameview method that would turn true after drawing in the loop so I resumed thread, waiter for boolean to turn true and paused it immediately, and that also crashed the app

Btw he just wants it to start, I want it to be visible but still paused after resuming an activity. I can simply call resume from onResume and after resuming the activity the game resumes and i can play, but thats not the problem. If I dont call that resume, there is black screen but when I tap top right corner it resumes and i can play again, not sure if you're following;d

EDIT: I fixed it. I added a boolean in surfaceview class, and a method that allows you to set value of that boolean, so that I can do it from activity class. In my activity class in onResume I only added if the game is paused, set value of that boolean to true and resume the game.

In the main game loop it checks after drawing and if the boolean is true it pauses the game again. What was left to do is to change drawing, so that when the boolean is true, even though the game is not paused it would draw a resume button on screen, everything works like a charm now :)
[Java for Android App Development] nikwen:
No, technically he wants exactly what you want. He opens another Activity (you open another app -> an Activity) and goes back to the one with the SurfaceView. Then it is black.

Do that in onResume():

mySurfaceView.resume(); //replace it with the name of your view

and in onPause():

mySurfaceView.pause(); //replace it with the name of your view

(Add both at the end of your methods.)

You do not need to overwrite these methods of the SurfaceView.
[Java for Android App Development] Wampirate:
As I wrote before I fixed the black screen :) If as you wrote I would add view.resume() in onResume, it would resume the game itself, and I wanted to keep it paused.

I was at the store today to test my app, I tested it on 3 deviced (sgs1,galaxy note 2, galaxy sIV).

On sgs1 it worked like a charm, everything was OK. Unfortunately on both note2 and sgsIV the menu would show up but after pressing play it hangs on loading screen, so I believe it is connected with the memory issue, during loading. I'll lower the resolution of my bitmaps and maybe change something else, and in a week I'll visit the store again :D Top priority to get it to work flawlessly on each device I can test on :D

Too bad I couldn't see logcat on that phones to see was it really the memory issue.
[Java for Android App Development] nikwen:
Ah, I didn't understand that before. Sorry.

Good idea to test it on these devices. However, the AVDs should do that, too. Why don't you use those?

I really recommend rewriting the text part. Why do you use so many images which consume so much RAM if it can be done easier? The apk would also be smaller with just one image.
[Java for Android App Development] Wampirate:
On AVDs it crashes even more often, the app won't even start, the memory issue appears instantly :D

About the images :

It's because of my laziness, I spent so many hours of this menu and interface and now you're telling me to start over :D But I guess you are right. I'll try that article and post here if I have any questions regarding that.

But the thing is, how do I even get a screen with all letters in upper and lower cases + numbers and dots itd? I have downloaded a windows font, am I to do this image by myself? Moreover, how big the image should be, I'd like the letters to be sharp on full hd screen like in sgsIV
[Java for Android App Development] nikwen:
Hey, I really forgot about that.

When you said you downloaded a Windows font, I remembered that you can also use those files. (Not all formats but some of them, e.g. *.ttf fonts)

Here is a tutorial for that: http://androidapkdeveloper.blogspot.co.uk/2012/09/font-manager.html?m=1

---------- Post added at 01:38 PM ---------- Previous post was at 01:36 PM ----------

For the AVD: Somewhere you can define how much RAM an app can use.

Increase that value. However, do that JUST FOR TESTING. On real devices you cannot do that (without modifying system files).
[Java for Android App Development] Wampirate:
One important question:

Should I have all game bitmaps together as a sprite, and scale and draw them on the go? With dst and src rectangles? It will be better for memory, how about efficiency? Won't it lag to every draw create the rect ?

About the fonts I meant it all the time, how to use a ttf font. Thanks, I'll look into it. Now I can easily get rid of all these images. :D You should have told me before about it, I was convinced it is impossible :D
[Java for Android App Development] out of ideas:
You can flag a large heap in the manifest. I just came across something about it the other day.

but thats more of a hack than a fix really. It would be better to try to get that memory usage down.
[Java for Android App Development] Wampirate:
I estimate a reduction of memory usage by approximately 80% by just using canvas.drawText for interface instead of bitmaps with text I had before^^ So that problem is fixed and I expect it to work on all devices out there :) In case any problems occur that I can not fix I'll ask you guys :)
[Java for Android App Development] nikwen:
Yeah, sorry, I completely forgot about that. It's been a while since I programmed a game. ;)

I think it depends on the kind of bitmap.

I would use those big bitmaps just for textures or, if you've got animations, for the single images of the animation.

In all other cases I would use seperate bitmaps. (It wouldn't make sense to put the player, hearts for the lifes and the background into one picture.)

And if you use the rectangles, I would create them only once and store those objects. Try to create as few objects as possible. It will consume a little bit more RAM but that should be worth the performance boost.
[Java for Android App Development] Wampirate:
Hey, I tested my game again.

It doesn't crash now, only it lags a bit, especially on sgs4. Why is that? Even my phone kinda overheats.

I mean on sgs4 it lags pretty bad, it kinda bothers me ;d It lags on mine as well but just a bit, but it used not to lag I think. I added some lines of code to gameUpdate method, can it be the issue here? A few more if statements may cause that? Or maybe the problem lies again in the game loop :D

That it the last issue I need to improve and the game is finished pretty much :)
[Java for Android App Development] nikwen:
Hm, I do not know your code, so I cannot tell you.

However, Google published a new tool for analizing the performance of apps, e.g. which actions take much time.
[Java for Android App Development] Wampirate:
And that tool is called?
[Java for Android App Development] nikwen:
It is called Systrace.

Links:

http://developer.android.com/tools/debugging/systrace.html

http://developer.android.com/about/versions/jelly-bean.html#43-tools
[Java for Android App Development] nikwen:
Hey,

it took me some time, but I found a solution. This is working for me:

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class MainActivity extends Activity {

private myView mv;
[MENTION=439709]override[/MENTION]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mv = new myView(this);
setVisible(true);
setContentView(mv);
}

public class myView extends SurfaceView {
private SurfaceHolder holder;
private Bitmap background;
private Canvas c;
private Paint myPaint;
private float x=100,y=100;

public myView(Context context) {
super(context);
holder = getHolder();
myPaint = new Paint();
setWillNotDraw(false);
}

private void redraw(){
c= null;
c = holder.lockCanvas();
synchronized(holder){
doDrawing(c);
}
holder.unlockCanvasAndPost(c);
}

private void doDrawing(Canvas d){
myPaint.setColor(Color.RED);
d.drawARGB(255, 0, 0, 0);
d.drawBitmap(background, 0, 0, null);
d.drawCircle(x, y, 20, myPaint);
}

[MENTION=439709]override[/MENTION]
public boolean onTouchEvent(MotionEvent event) {
setWillNotDraw(true);
int action = event.getAction();
switch (action){
case MotionEvent.ACTION_DOWN:
x = event.getX();
y = event.getY();
break;
}
redraw();
return true;
}

[MENTION=439709]override[/MENTION]
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);

doDrawing(canvas);
}

[MENTION=439709]override[/MENTION]
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
background = BitmapFactory.decodeResource(getResources(), R.drawable.bg);
background = Bitmap.createScaledBitmap(background, w, h, true);
}

}

}
[Java for Android App Development] Wampirate:
Haha it looks we posted in the same moment :D Look at my post, edited :) If your method works then there are 2 possibilities :) Thanks anyways:)
[Java for Android App Development] nikwen:
Yeah, saw it now. :laugh:
[Java for Android App Development] Wampirate:
EDIT:

Is there a way to call activity class method from view class?
[Java for Android App Development] nikwen:
You could try to mix the accepted answers here: http://stackoverflow.com/questions/7745902/how-can-a-custom-view-get-access-to-its-activity

And here: http://stackoverflow.com/questions/3901590/get-activity-object-while-in-view-context
[Java for Android App Development] FE4RLESSxSH4D0W:
Need Help Making My Own Game

Hi! I have been thinking about making a game for a few months now and have been doing some research and watching many tutorials on how to make them. I cant seem to find a tutorial similar to the game I want to make and I have no idea where to start. I want a game where the screen constantly moves and there are obstacles that you must jump over and also you can jump more than once. can anyone help me or show me a good place to start? I really appreciate it!!
[Java for Android App Development] FE4RLESSxSH4D0W:
Thank you! I followed a little bit of the kilobot tutorial before but i keep getting flustered. I can never seem to figure out how to put in my own code to get it to work how I want. I am using java and eclipse if that helps. Out of curiosity, but are you a programmer?
[Java for Android App Development] FE4RLESSxSH4D0W:
I guess I will just read it again and again until it starts to click, that seems to be the gist of understanding how to program so far for me :/ But that is kind of what I want to do, make a simple game that I can put on the app store for free and make money by ads. lol.
[Java for Android App Development] nikwen:
Have a look at engines like Andengine or libgdx as well. ;)
[Java for Android App Development] nikhilroxstar:
Can I find and download free music using this app on my Micromax A190??
[Java for Android App Development] Ryan.T.Student:
Game Maker Studio is likely better for a beginner if doing 2D, while Unity is probably the best choice for 3D.
[Android Q&A, Help & Troubleshooting] GTMoraes:
[Q] Phone get stuck with screen locked. Rebooting starts an endless "startloop"

(I posted on the wrong location first time, sorry)

Hi, I have this Galaxy S3 i9300, with Wanam ROM and Boeffla-Kernel 2.12.

Sometimes, when I lock the screen, it just freezes in there. I'm unable to wake it up, and the LED keeps flashing the last notification.

Most of the time, I get notice of it when I receive a notification (it rings) and the phone cannot wake up. Calling and trying to trigger another notification does not wield any results.

The weird part is this: When I restart it, the OS starts as it should, but it "skips" the lockscreen (when I restart my phone, first thing I'm presented is the pattern lockscreen, all Android default), and it goes directly to the home screen. The touch screen is unresponsive (but it does vibrate when I press any of the two bottom buttons), but phone is still alive (few animations plays smoothly).

Then it restarts. The startup LED (fading blue to bright blue) doesn't turn off (normally it would turn off even before the lockscreen is presented).

Disabling the lockscreen wouldn't solve the problem, nor does starting on "safe mode". Same issue.

Booting into CWM and wiping data/cache folders solves it, but resets my phone. Restoring a backup (data folder only) also works.

Funny fact is that even with a fresh backup (which works), it might just hang up like before (although I didn't modify/install anything).

Logging files should give me some info, but I don't know how to retrieve them, let alone on this condition.

The only step I did so far to try to solve it was to disable a notification program (Logical, it seems to hang up when I receive a notification, and as a wipe to the data folder solves it, I presume it's an rogue app. But never, ever I had a problem with this app, but who knows if on an update, it's crashing my phone)

Does anyone have any information regarding to this? I've never seen something like that.

How do I recover my logfiles during an emergency?

-----------

Had another lock-up. No notifications received and the notification app was disabled. How do I get the log file?
[HTC Wildfire S] ekids1234:
I flash my wfs, and it stop at htc logo.

Use this

http://xdaforums.com/showthread.php?t=2206780

Title:

ROM][AROMA][JB]Marvellous

CM10[BUGFREE][STABLE][SMOOTH]

[25-06-2013]

After I flashed, reboot, then stop at logo.

p. s. I am a Taiwanese. My grammer might appear mistake.

Kindly give me your advice.
[HTC Wildfire S] linasj:
The installer of that ROM is bugged, so you will have to wait for it to be updated. Or you can always choose a different ROM. Personally, when I tried this ROM, it didn't stop loading at the logo, instead it booted into the previous ROM I had. Anyway, just wait for a fix.
[HTC Wildfire S] AndromacK:
Hi,

I have exactly the same problem and I thought it was a S-OFF problem.

My phone is S-ON but with unlocked bootloader and rooted.

Are you sure this is due to the installer? I tried other CM10 and same problem.

Everything is OK with the stock ROM.
[HTC Wildfire S] thehacka1:
You don't need S-OFF to try different roms. Tell me sir do you have a marvel or marvelc? If you have a marvelc then you are flashing the wrong roms.
[HTC Wildfire S] linasj:
THIS. There's not much you can do to mess up install process, unless you don't follow the intructions (or have them in your head, for that matter). Or the whole flashable zip might be messed up. Either way, make sure you're flashing ROM designed for your device. As for the Marvelous CM10, I'm sure it's the installer, you can look on its thread in these forums. Fix should be in progress.
[HTC Wildfire S] ekids1234:
your suggest

So, what rom is your suggest?

Thanks for your reply~^o^~
[HTC Wildfire S] linasj:
I'd go with either CM10.1 by OWL PROJECT (http://xdaforums.com/showthread.php?t=2283549) or Android Open Kang Project (AOKP) (http://xdaforums.com/showthread.php?t=2262394). I'm currently using the latter one. Quite happy with it so far.
[HTC Wildfire S] ekids1234:
please teach me

I read your reply. How to recognize marvel or marvelc?

Both of them are wildfire s?
[HTC Wildfire S] ekids1234:
different

I just see it.

Could you tell me that

IN this situation,can I send music or app to my friend by bluetooth?

What will not work?(for example...)
[HTC Wildfire S] thehacka1:
Look in About Phone section of your device. It will say A150c instead of A150e if you are marvelc. Also if you don't have a removable sim then you have a marvelc.
[HTC Wildfire S] ekids1234:
ok~

My phone is A150e.

And I can use it to call.

So my phone is marvel?
[HTC Wildfire S] thehacka1:
Yes it is. It's strange you are getting these errors. When did you purchase your phone? If you did it in 2012 or 2013 then you need to flash this: http://d-h.st/tA3 after flashing rom.
[HTC Wildfire S] ekids1234:
my god!

I can't use bluetooth....I can't open it.

I flash the latter one.
[HTC Wildfire S] ekids1234:
my another Q

I find a stranger thing.

I flash "Android Open Kang Project (AOKP)" this rom,and it just said "com.android.phone is stoped" &"systemUI is stoped" once two seconds.

everytime I boot the phone it ends up on the welcome screen with a warning in the middle saying "Unfortunately, the process com.android.phone has stopped." and if I press "OK" you can see that behind this pop-up-dialogue was another pop-up saying "Unfortunately, System UI has stopped." , but after half a second the first warning pops up again - and it will do so no matter how often you press "OK"....
[HTC Wildfire S] linasj:
That's just bizzare. Try contacting the ROM developer, I'm sure he'll have a solution to this.
[HTC Wildfire S] ekids1234:
but

I wamt to do this,but I clicked,and he said I MUST write more than 10 posts.

Could you contact him for me?
[HTC Wildfire S] linasj:
You're 2 posts short of 10 posts, just go post something useful/informative somewhere on these forums, and you'll be good to go. ;)
[HTC Wildfire S] ekids1234:
Oh,I restored to my original andriod2.3.5 rom.

By the way,I purchased my phone in 2012,so i needed to flash that kernel after i flash Rom.

But,when i restored to original ROM,i can't overclock.

How can i do?
[HTC Wildfire S] EdikNeznanov:
You are at stock now. Without root, custom kernel( maybe even without cwm) . You should flash custom kernel with cwm. Try cake or dust kernel.
[HD2 Android Q&A, Help & Troubleshooting and Genera] Zippy1970:
I just wiped my stock ROM HD2 (Task29) because I want to install MIUI on it. After the wipe I installed MAGLDR on it (v1.13) but when I rebooted the HD2, I was greeted with the white HTC screen. I hadn't checked my HSPL version and it turned out to be 3.03. So I downgraded to SPL-2.08.HSPL and retried installing MAGLDR. But after reboot, I still get the white HTC screen.

So what am I doing wrong?
[HD2 Android Q&A, Help & Troubleshooting and Genera] Marvlesz:
Which radio are you on?

If I remember correctly, MAGLDR requires a radio 2.08 and above. Try to flash radio 2.15 and see what happens.
[HD2 Android Q&A, Help & Troubleshooting and Genera] Zippy1970:
Yes, that was it. :)

I thought I had 2.15 installed but that was on my other HD2 (I have two). Turned out this one had 2.07. Flashed 2.15 and I was able to install MAGLDR without a hitch!
[Galaxy S I9000 Q&A, Help & Troubleshooting] hardgore:
rom? kernel? overclock? enlarge ram?

i have cm10.1 stable

thanks!! : )
[Galaxy S I9000 Q&A, Help & Troubleshooting] idroj:
change rom

GamerzROM, CyanAOSP, or 4.1.2 base rom
[Galaxy S I9000 Q&A, Help & Troubleshooting] darkknigh_t:
Gamerzrom it comes with devil kernel :)
[Galaxy S I9000 Q&A, Help & Troubleshooting] compacity:
pick up some bloated rom + OC kernel n enlarge memory + script/binary/init.d tweak + slim pack gapps.
[Galaxy S I9000 Q&A, Help & Troubleshooting] bozalic:
Gamerz rom v4 + devil kernel stock settings + % 110 live oc + autokiller memory optimizer pro best settings for me.

Sometimes lagging after asphalt 6.

İ think its normal for 4.2.
[Galaxy S I9000 Q&A, Help & Troubleshooting] compacity:
actually u can get free lag by script tweak, n autokiller quite lame app (sorry but i need to say that) as u already got da best setting u mention, so why use autokiller as it use more ram.

juz expressing my opinion mate :)
[Galaxy S I9000 Q&A, Help & Troubleshooting] bozalic:
More ram more game i think.

And big battery capacites need fastest sgs:)
[Galaxy S I9000 Q&A, Help & Troubleshooting] hardgore:
thanks! :D

i installed the gamerzrom.. so i anderstand that i need to change some things, and its not already set to ultimate..?

is there an app / rom / anything else that do it all automatically to ultimate?

i really new at all this so its like chinese to me, anyway i try my best : )

i have some questions about the devil tools :

in cpu, i see min cpu 400 MHz, max 1000 MHz, and also - oc value 100%, oc target low 800 mhz, oc target high 1400,

whats the diffrents? i thought i will see a button for just - normal / fast thats all ;D

and also i saw in the recovery > devil > performance 3 options : smooth, normal, power save

whats this? is this maybe what i wrote about " normal / fast" ?

i installed the autokiller memory optimizer and also the pro from the black mart (only the pro) , and it says to me that the licence not good.. do u have any ideas to fix it?

what? how?

what is "script tweak"?

what is asphalt?

i see in the devil tools that there are lots of options, is there maybe manual / dictionary?

ya man : )