Android :: Print Integer To Canvas Fast And Without Garbage Collects?

Nov 24, 2010

I have a tight game loop in a separate thread where I paint a lot of things on the canvas.

When I paint the score to the canvas I use the following function code...

When I check allocations in ddms I see that .toString not totally unsurprising allocates a char array on each conversion from an Integer to a String. This array will eventually be claimed by the garbage collect and cause uneven rendering of frames on slow android devices.

Is there a better way of painting integers on a canvas that won't cause new allocations and garbage collects?

Android :: Print integer to canvas fast and without garbage collects?


Android :: Add Integer To Screen And Print Answer Loop Wise

Aug 31, 2010

Rather than do this by just creating a lot of strings (which I've already managed), I want to add an integer and then print those list to the screen. At the moment, I'm just trying to get one integer on the screen without even adding it, but the app is "force closed" in the emulator. Why doesn't this work? Add one to it and then print the answer to this for a given loop (say up until 10).

Code:
package com.monkeez.count;
import android.app.Activity;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.TextView;
public class Count extends Activity {
/** Called when the activity is first created. */
TextView countDisplay;
@Override public void onCreate (Bundle savedInstanceState) { int counter = 1;
countDisplay = new TextView(this);
this.setContentView(countDisplay);
countDisplay.setText("counter here");
} }

The log cat is thus:
09-01 09:54:07.051: DEBUG/AndroidRuntime(279): AndroidRuntime START
09-01 09:54:07.051: DEBUG/AndroidRuntime(279): CheckJNI is ON
09-01 09:54:07.401: DEBUG/AndroidRuntime(279): --- registering native functions ---
09-01 09:54:08.891: DEBUG/dalvikvm(193): GC_EXPLICIT freed 320 objects / 19376 bytes in 109ms
09-01 09:54:09.041: DEBUG/PackageParser(65): Scanning package: /data/app/vmdl48927.tmp
09-01 09:54:09.251: INFO/PackageManager(65): Removing non-system package:com.monkeez.count
09-01 09:54:09.251: INFO/ActivityManager(65): Force stopping package com.monkeez.count uid=10037
09-01 09:54:09.991: DEBUG/PackageManager(65): Scanning package com.monkeez.count
09-01 09:54:09.991: INFO/PackageManager(65): Package com.monkeez.count codePath changed from /data/app/com.monkeez.count-2.apk to /data/app/com.monkeez.count-1.apk; Retaining data and using new
09-01 09:54:10.011: INFO/PackageManager(65): /data/app/com.monkeez.count-1.apk changed; unpacking
09-01 09:54:10.054: DEBUG/installd(34): DexInv: --- BEGIN '/data/app/com.monkeez.count-1.apk' ---
09-01 09:54:10.511: DEBUG/dalvikvm(286): DexOpt: load 169ms, verify 64ms, opt 4ms
09-01 09:54:10.591: DEBUG/installd(34): DexInv: --- END '/data/app/com.monkeez.count-1.apk' (success) ---
09-01 09:54:10.602: WARN/PackageManager(65): Code path for pkg : com.monkeez.count changing from /data/app/com.monkeez.count-2.apk to /data/app/com.monkeez.count-1.apk
09-01 09:54:10.602: WARN/PackageManager(65): Resource path for pkg : com.monkeez.count changing from /data/app/com.monkeez.count-2.apk to /data/app/com.monkeez.count-1.apk
09-01 09:54:10.611: DEBUG/PackageManager(65): Activities: com.monkeez.count.Count
09-01 09:54:10.650: INFO/ActivityManager(65): Force stopping package com.monkeez.count uid=10037
09-01 09:54:11.631: INFO/installd(34): move /data/dalvik-cache/data@app@com.monkeez.count-1.apk@classes.dex -> /data/dalvik-cache/data@app@com.monkeez.count-1.apk@classes.dex
09-01 09:54:11.641: DEBUG/PackageManager(65): New package installed in /data/app/com.monkeez.count-1.apk
09-01 09:54:11.821: DEBUG/dalvikvm(65): GC_FOR_MALLOC freed 6733 objects / 446400 bytes in 140ms
09-01 09:54:12.561: INFO/ActivityManager(65): Force stopping package com.monkeez.count uid=10037
09-01 09:54:12.711: DEBUG/dalvikvm(126): GC_EXPLICIT freed 1940 objects / 106408 bytes in 121ms
09-01 09:54:13.351: WARN/RecognitionManagerService(65): no available voice recognition services found
09-01 09:54:13.831: DEBUG/dalvikvm(65): GC_EXPLICIT freed 4667 objects / 280056 bytes in 173ms
09-01 09:54:13.901: DEBUG/dalvikvm(165): GC_EXPLICIT freed 2326 objects / 125088 bytes in 1059ms
09-01 09:54:14.180: INFO/installd(34): unlink /data/dalvik-cache/data@app@com.monkeez.count-2.apk@classes.dex
09-01 09:54:14.271: DEBUG/AndroidRuntime(279): Shutting down VM
09-01 09:54:14.290: DEBUG/dalvikvm(279): Debugger has detached; object registry had 1 entries
09-01 09:54:14.340: INFO/AndroidRuntime(279): NOTE: attach of thread 'Binder Thread #3' failed
09-01 09:54:15.350: DEBUG/AndroidRuntime(291): AndroidRuntime START
09-01 09:54:15.350: DEBUG/AndroidRuntime(291): CheckJNI is ON
09-01 09:54:15.740: DEBUG/AndroidRuntime(291): --- registering native functions ---
09-01 09:54:16.960: INFO/ActivityManager(65): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.monkeez.count/.Count }
09-01 09:54:17.120: DEBUG/AndroidRuntime(291): Shutting down VM
09-01 09:54:17.170: DEBUG/dalvikvm(291): Debugger has detached; object registry had 1 entries
09-01 09:54:17.250: INFO/AndroidRuntime(291): NOTE: attach of thread 'Binder Thread #3' failed
09-01 09:54:17.301: INFO/ActivityManager(65): Start proc com.monkeez.count for activity com.monkeez.count/.Count: pid=298 uid=10037 gids={}
09-01 09:54:18.611: WARN/ResourceType(298): No package identifier when getting value for resource number 0x00000001
09-01 09:54:18.620: DEBUG/AndroidRuntime(298): Shutting down VM
09-01 09:54:18.620: WARN/dalvikvm(298): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): FATAL EXCEPTION: main
09-01 09:54:18.680: ERROR/AndroidRuntime(298): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.monkeez.count/com.monkeez.count.Count}: android.content.res.Resources$NotFoundException: String resource ID #0x1
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at android.os.Handler.dispatchMessage(Handler.java:99)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at android.os.Looper.loop(Looper.java:123)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at java.lang.reflect.Method.invokeNative(Native Method)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at java.lang.reflect.Method.invoke(Method.java:521)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at dalvik.system.NativeStart.main(Native Method)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x1
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at android.content.res.Resources.getText(Resources.java:201)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at android.widget.TextView.setText(TextView.java:2817)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at com.monkeez.count.Count.onCreate(Count.java:19)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-01 09:54:18.680: ERROR/AndroidRuntime(298): ... 11 more
09-01 09:54:18.940: WARN/ActivityManager(65): Force finishing activity com.monkeez.count/.Count
09-01 09:54:19.470: WARN/ActivityManager(65): Activity pause timeout for HistoryRecord{43fb6718 com.monkeez.count/.Count}
09-01 09:54:19.550: INFO/ARMAssembler(65): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x2de138:0x2de1f4] in 602730 ns
09-01 09:54:22.523: WARN/InputManagerService(65): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@43f92978
09-01 09:54:22.681: INFO/Process(298): Sending signal. PID: 298 SIG: 9
09-01 09:54:22.826: INFO/ActivityManager(65): Process com.monkeez.count (pid 298) has died.

And the Count Manifest.xml is thus:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.monkeez.count"
android:versionCode="1" android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Count" android:label="@string/app_name">
<intent-filter> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </activity> </application>
<uses-sdk android:minSdkVersion="8" /> </manifest>

It seems that the parser on this site doesn't like to render my xml file - you can see it at
http://pastebin.com/raw.php?i=W75ak3E9

View 2 Replies View Related

Android :: Canvas.drawText(...) Does Not Print Linebreak

Jun 30, 2010

I tried to write some text on a surface view I created. It works fine, if title is false, and there is no linebreak added to the text. But if I add a title and therefore a linebreak, the linebreak isn't printed as expected, but instead there is this symbol [] printed.

CODE:...................

View 1 Replies View Related

Android :: Reset Canvas - Draw A New Bitmap Into The Canvas

Jul 7, 2010

My loadMap() method generate a canvas.throwIfRecycled exception when i try to load a new map.
When i start the game, the initial map loads and work fine though,
its only when i try to load a new map that i get the exception ..

How can i "reset" canvas and the bitmap i use to draw into, so i can startover fresh with them ?
here's what i use to create and draw my maps:

CODE:.........

So basicaly once i created and used picDest and canvas, i cannot figure how to reset it all for when i want to load a new map..

View 1 Replies View Related

Android :: Thread(s) Producing Garbage?

May 27, 2010

I have an app with about 15 threads. Most do mundane tasks and sleep most of their lives. Others collect information and cache it in hashmaps. The hashmaps grow to a moderate size and level out. The number of keys and size of value remains constant, but the contents of the values changes (at 33 keys per second average). When I start my app, I notice the garbage collection interval goes from minutes to once per second, and the amount of garbage is 700k+ each time. In fact as I was writing this, it caused my phone to reboot with an error "Referencetable Overflow". Here's my question: Are there any tricks to identifying which threads are producing the garbage, or even finding out more about what garbage they are producing?

05-26 22:08:57.052 W/dalvikvm( 1031): ReferenceTable overflow (max=512)
05-26 22:08:57.052 W/dalvikvm( 1031): Last 10 entries in JNI local reference table:
05-26 22:08:57.052 W/dalvikvm( 1031): 502: 0x449904a8 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031): 503: 0x4494fda8 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031): 504: 0x44a172c8 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031): 505: 0x448c7900 cls=Ljava/lang/String; (28 bytes)........

View 2 Replies View Related

Android :: Determine Whether An Integer Is Even / Odd?

Sep 29, 2010

I feel stupid asking such a simple question, but is there an easy way to determine whether an Integer is even or odd?

View 5 Replies View Related

Android :: Need To Replace Garbage Keyboard Bundled With 1.6

Feb 11, 2010

Was looking for some guidance here. I need to replace the garbage keyboard bundled with 1.6 for something else. Which in your opinion is the best replacement and why? Maybe some comparisons would help also. Oh, by the way i'm running a mytouch 3g!

View 28 Replies View Related

Android :: Garbage Collector Conservation - Best Practice

Jul 29, 2009

I didn't use much Java before Android so my knowledge concerning the gc is marginal. Now I'm developing a highly physics-based game and therefore I need to do many calculations each time step and many (25) time steps per second. At the moment I'm almost only using local objects (float) in my methods, so I guess they are allocated every time the method is called (which might be, for example, 25*100 = 2500 times a second , for 100 objects with calculations on them). This causes massive activity of the garbage collector like freeing ~10000 objects every 1-2 seconds (taking ~200ms on a real device). Now I really want to optimize that because even there's no noticeable delay due to the GC (and the frame rate is constant), this seems just not well. But I read on many documentations concerning Java optimization, that there is not much to optimize in modern versions of (desktop) Java, because the GC is fast enough. Does this apply to Android, too? Does the compiler optimize anything like frequently, steady allocated objects (like floats)? What would be best practice: keep all local objects and allocate and free them all the time or use class-global objects, even if they are only used inside one particular method (which is bad programming style but conserves GC?

View 5 Replies View Related

Android :: Possible To Stop Droid Garbage Collector?

May 21, 2010

Is there any way to stop the garbage collector for some time?

View 2 Replies View Related

Android : Latency Due To Garbage Collection On On PrevFrame

Jun 6, 2010

I'm writing an Augmented Reality codes that should works in realtime,

But the VM's garbage collection hinders my program's performance.

I checked my program's execution time for each in OnPrevFrame(byte[], Camera)

and it execution time increases from around 50ms to 120ms at just after each garbage collection.

I copied parts of logs below. (local time is just before and after of signal processing, and global time is time stamps for every onPreviewFrame() calling )Also I executed onPreviewFrame without any signal processing on it, but

the garbage collection is also carried showing debugging message around 60ms it spends for memory release.

Is this garbage collection come from releasing byte[] yuvs image data? ( i uses 320x240 thumb nail )

then this clearly comes from Java's limitation, so there will be no hope for improvement unless

I found a way to directly access camera device? do you think this is feasible? Hope listen to others' comments.

View 3 Replies View Related

Android :: Menuitem Id In Xml Format Can't Be An Integer?

Mar 16, 2010

in menu.add, you add an integer menuitem id.But when you specify the menu in xml, @+id can't take an integer, so you can't test the id for the menu item as an integer in a switch statement.What obvious thing am I missing, because surely an inconsistency this bone-stupid couldn't have passed muster with all those wonderful geniuses at Google.

on top of that, when I give the menu item a name like "@+id/myMenuItem", item.getItemId() returns an integer, a long one, which I guess is a representation of the hex pointer.

View 3 Replies View Related

Android :: Show Integer From Activity In XML?

May 18, 2010

I started two days ago with android, gone through the hello android stuff and also started to read the Hello Android book, which is great.

PROBLEM:

I use in my app - VERY EASY APP- the XML output. So basically the main activity just tells the android to show the XML layout of main.

But what if I have in the activity - code defined integer variable and I want this integer variable also be shown on the display?

How do I PUSH the integer variable to the XML??? From main XML reference to other strings in XML is easy - @string/app_name ... but how do I use the integer variable from the activity?

View 2 Replies View Related

Android :: Glbuffersubdata With An Offset Into Buffer Without Causing Garbage

Aug 1, 2010

I'm trying to update part of a VBO with a call to glBufferSubData(). When I update from the start (0) of my existing shadow buffer, there is no problem, as the buffer starts reading from 0. The following will read 0 to y from the buffer and place it at 0 to y in the VBO: gl.glBufferSubData(GL11.GL_ARRAY_BUFFER, 0, y, mPositionBuffer);

However, if I want to update a portion of the VBO (not from 0) I run into a problem; The following doesn't work, since it will write the values from the start of the buffer (0 to y) into position x to x+y of the VBO:........................

View 1 Replies View Related

Android :: Avoiding Garbage Collection For Smooth 2d Animations

Dec 28, 2009

I'm drawing a rect to a surfaceview. Nothing special, just a test like this, in the surfaceview-extended class:

private int mPosX = 0; private Paint mPaint = new Paint(); Code...

the rect just bounces around the screen. I'm watching DDMS, I still see the garbage collector being called, even with this simple draw loop. There is no other application code being executed.

I'm wondering if it's realistic to expect the gc to not be called at all if we take care to not allocate any objects during our draw loops. I'm trying to extend this example to do some smooth animations, but every once in awhile the gc is called and you can see the drawing stutter. Although none of my application code is allocating any new objects, I don't know what the underlying API is doing inside surfaceview etc, and I doubt we can control that. Just wondering if this is not possible, I'd prefer to abandon this game idea up-front if we can't guarantee smooth animation.

View 5 Replies View Related

Android :: Droid Camera Garbage Collection / Way To Avoid It

May 25, 2009

I am developing a camera application , where the frame rate is important. However, camera uses a preview callback function which allocates a byte[] array of 230400 bytes, which makes it necessary for the garbage collection to step in. Can someone suggest me a way to avoid garbage collection stepping in?

View 10 Replies View Related

Android : OpenGL Garbage Collection - With Direct ByteBuffers

May 20, 2009

Hi, I have discovered while using DDMS that the basic OpenGL system calls in my code are allocating memory and causing the garbage collector to fire! It's not the system calls themselves causing the problem but the use of direct byte buffers to pass data in.

The direct byte buffers I use in calls such as glVertexPointer & glTexCoordPointer lead to java.nio calls to read the byte buffers, leading to objects of type org.apache.harmony.luni.platform.PlatformAddress being created.

These buffers are the same as in the example OpenGL code. I am creating a ByteBuffer using allocateDirect() and then creating an IntBuffer using ByteBuffer.asIntBuffer() to pass data to the OpenGL functions. The problem occurs as the system is reading the buffers.

Is there a way around this? Maybe using something other than direct byte buffers? It seems that using this method, OpenGL code of any complexity (ie a lot of OpenGL system calls in every frame) is doomed to pause a lot. I am aware that these calls should be kept to a minimum, but I still need to use a certain amount of them.

View 9 Replies View Related

Android : Are Primitive Types Garbage Collected In Droid?

Mar 18, 2010

I know this may be a dumb question, but my background is more in c++ and managing my own memory.

I am currently cutting down every single allocation that I can from one of my games to try and reduce the frequency of garbage collection and perceived "lag", so for every variable that I create that is an Object (String for example) I am making sure that I create it before hand in my constructor and not create temporary variables in simple 10 line functions... (I hope that makes sense)

Anyways I was working though it some more tonight and I realized that I a may be completely wrong about my assumption on garbage collection and primitive types (int, boolean, float) are these primitive type variables that I create in a 10 line function that gets called 20 times a second adding to my problem of garbage collection?

View 2 Replies View Related

Android :: Unable To Parse 53.6 As An Integer - Should Be The Subject

Jul 31, 2010

I got an exception "Unable to parse 53.6 as an integer".

What is the proper format?

CODE:.....................

View 1 Replies View Related

Android :: Integer Return When User Read The Sms

Mar 8, 2010

I want to do some activity on sms after user read it, so how can my background service in android know that particular sms is now read(when my service start work) to react for some task.

Is there system generate any integer when user read sms. if it generate than how will i get?

View 1 Replies View Related

Android :: Getting Integer Expected Error In Manifest?

Aug 16, 2010

In the android manifest on the first line "" I'm getting an error marker (with a red X). When I mouse over the red x it says- "Manifest attribute 'minSdkVersion' is set to '2.1'. Integer is expected."

View 1 Replies View Related

Android : Sax Parser Character Array To Integer?

Apr 4, 2010

I am trying to get the contents of tags into variables in my java Sax parser. However, the Characters method only returns Char arrays. Is there anyway to get the Char array into an Int? code...

View 1 Replies View Related

Android : Spinner Cannot Load An Integer Array / Way To Fix

Apr 19, 2010

I have an application, which has a Spinner that I want populated with some numbers (4,8,12,16). I created an integer-array object in strings.xml with the items mentioned above, set the entries of the Spinner to the integer-array, and when I run the app I get:

04-19 23:38:48.016: ERROR/AndroidRuntime(10193): java.lang.NullPointerException
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:355)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:198)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.View.measure(View.java:7965)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:888)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.LinearLayout.measureVertical(LinearLayout.java:350)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.View.measure(View.java:7965)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.View.measure(View.java:7965)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.LinearLayout.measureVertical(LinearLayout.java:464)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.View.measure(View.java:7965)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.View.measure(View.java:7965)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.ViewRoot.performTraversals(ViewRoot.java:763)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.view.ViewRoot.handleMessage(ViewRoot.java:1632)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.os.Handler.dispatchMessage(Handler.java:99)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.os.Looper.loop(Looper.java:123)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at android.app.ActivityThread.main(ActivityThread.java:4310)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at java.lang.reflect.Method.invokeNative(Native Method)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at java.lang.reflect.Method.invoke(Method.java:521)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-19 23:38:48.016: ERROR/AndroidRuntime(10193): at dalvik.system.NativeStart.main(Native Method)

As soon as I changed the array to a string-array, this works fine. Is this normal? I realize that I can (and will) just convert the string array values to an int, but it seems weird that I have to.

View 1 Replies View Related

Android :: Avoid Garbage Collection Delays In Java Games?

Mar 20, 2010

I'm performance tuning interactive games in Java for the Android platform. Once in a while there is a hiccup in drawing and interaction for garbage collection. Usually it's less than one tenth of a second, but sometimes it can be as large as 200ms on very slow devices. I am using the ddms profiler (part of the Android SDK) to search out where my memory allocations come from and excise them from my inner drawing and logic loops. The worst offender had been short loops done like,

for(GameObject gob : interactiveObjects)
gob.onDraw(canvas);........................

View 3 Replies View Related

Android :: Force Garbage Collection To Happen At Convenient Time?

Apr 15, 2009

I have screen 1 of my app which I want to transition smoothly into screen 2.

I want the transition to be smooth but I don't mind a slight pause before or after the transition. Before the transition I dump a lot of objects that are no longer needed from screen 1.

However, as luck would have it (!), the garbage collection almost always takes place during the transition causing the frame rate to drop and the transition looks terrible :(

Is there a way for me to either force the garbage collection to complete before the transition or delay until after the transition is finished? I have tried System.gc() in various places but it doesn't seem to help performance.

View 2 Replies View Related

Android :: Get Screen Resolution / Pixels As Integer Values

May 25, 2010

How can I quickly access the screen resolution (width, height) as integer values? I've tried this one, but it always shows zero on my emulator:

DisplayMetrics dm = new DisplayMetrics();
int width = dm.widthPixels / 2;

In my case I want to dynamically create a table with tableRows, each containing two cols. This cols all shall fill half of the screen in width.

View 1 Replies View Related

Android :: Save Configuration Value As Integer In Preference Activity?

Sep 16, 2010

Is there a way how I can tell the Preference Activity that value should be saved as integer? So far my all values are saved as strings... I can limit input to integers via XML easy:

<EditTextPreference android:key="SomeKey" android:numeric="integer" />

but it is still saved as string and later trying to getInt("SomeKey") on preferences object I always get java.lang.ClassCastException: java.lang.String.

Is there a way that EditTextPreference value would be saved not as string? Or maybe I should use some other type of Preference for numeric input?

View 7 Replies View Related

Android : Need To Create Bitmap From Integer Array In C / OpenGL

Nov 29, 2009

I am trying to move my code from Java to C, and I have encountered a problem while trying to find a function in C that can take an array of ints and create a bitmap from it for OpenGL. In Java, I used

bitmap = Bitmap.createBitmap( {int array name} , w, h, Config.RGB_565);

Is there a similar function that I can use in C, or a workaround that I could use?

Also, if it matters, I am programming for Android.

View 4 Replies View Related

Android :: MotionEvent And KeyEvent Causing Excessive Garbage Collect (GC) Calls

Jan 3, 2010

I'm running into some issues with input events and garbage collection, or more precisely object allocation. I am creating a game and have pretty much got my head around the OpenGL environment. I've digested all the relevant material I could find regarding performance, memory allocation etc (and watched the excellent presentation by Chris Pruett - http://code.google.com/events/io/2009/sessions/WritingRealTimeGamesAn...). I've pretty much eliminated any object allocations after initial setup from my game (which is still in its infancy), but I'm still getting a bunch of GC calls, like this:...........................

View 6 Replies View Related

Android :: How Can Check Current Time On Droid Device And Put Into Integer?

Nov 15, 2010

I know there is the Date() class built into the API, but line of code actually grabs the time of day?

View 3 Replies View Related

Android :: Setting Intent Extra Value That's An Array Of String And Integer

Aug 3, 2010

I have a program that sends a broadcast Intent that needs an "extra" value.The value is declared as being of type Object[], though I know that the elements are always of type Integer or String.That's part of an API not under my control. What's the most concise and/or efficient way to do the equivalent of the putExtra call below?

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved