Thursday, April 25, 2013

[android help] Memory overflow when loading large textures


I have a GLSurfaceView and a Renderer which loads textures in onSurfaceCreated. My textures are created like so :



public Texture3D(final GL10 gl, final int id) {
_pBitmap = BitmapFactory.decodeResource(Utils.getResources(), id);
gl.glEnable(GL10.GL_TEXTURE_2D);

gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
texture = newTextureID(gl);
gl.glBindTexture(GL10.GL_TEXTURE_2D, texture);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);

gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);


GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, _pBitmap, 0);

_pBitmap.recycle();
_pBitmap = null;

gl.glEnable(GL10.GL_BLEND);
}


I store them in an HashMap :



textures.put(R.drawable.tile, new Texture3D(gl, R.drawable.tile));


My problem is when I create a texture from a large image (720x1280, 561 Ko) after I sometimes get the following error :



04-24 11:05:19.870: D/dalvikvm(27953): GC_CONCURRENT freed 26K, 18% free 50397K/60743K, paused 18ms+6ms, total 57ms
04-24 11:05:19.870: D/dalvikvm(27953): WAIT_FOR_CONCURRENT_GC blocked 2ms
04-24 11:05:19.895: D/dalvikvm(27953): GC_FOR_ALLOC freed 7K, 18% free 50390K/60743K, paused 25ms, total 25ms
04-24 11:05:19.900: I/dalvikvm-heap(27953): Forcing collection of SoftReferences for 14745616-byte allocation
04-24 11:05:19.940: D/dalvikvm(27953): GC_BEFORE_OOM freed 10K, 18% free 50380K/60743K, paused 41ms, total 41ms
04-24 11:05:19.940: E/dalvikvm-heap(27953): Out of memory on a 14745616-byte allocation.
04-24 11:05:19.940: I/dalvikvm(27953): "GLThread 11210" prio=5 tid=35 RUNNABLE
04-24 11:05:19.940: I/dalvikvm(27953): | group="main" sCount=0 dsCount=0 obj=0x42ec2008 self=0x6095d078
04-24 11:05:19.940: I/dalvikvm(27953): | sysTid=29199 nice=0 sched=0/0 cgrp=apps handle=1623155456
04-24 11:05:19.940: I/dalvikvm(27953): | schedstat=( 142147207 17456123 110 ) utm=11 stm=2 core=2
04-24 11:05:19.940: I/dalvikvm(27953): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
04-24 11:05:19.945: I/dalvikvm(27953): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:623)
04-24 11:05:19.945: I/dalvikvm(27953): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:476)
04-24 11:05:19.945: I/dalvikvm(27953): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:499)
04-24 11:05:19.945: I/dalvikvm(27953): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:529)
04-24 11:05:19.945: I/dalvikvm(27953): at com.gbanga.opengl.Texture3D.(Texture3D.java:73)
04-24 11:05:19.945: I/dalvikvm(27953): at com.gbanga.opengl.Texture3D.setupTextures(Texture3D.java:169)
04-24 11:05:19.945: I/dalvikvm(27953): at com.gbanga.opengl.OpenGLRenderer.onSurfaceCreated(OpenGLRenderer.java:440)
04-24 11:05:19.950: I/dalvikvm(27953): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1494)
04-24 11:05:19.950: I/dalvikvm(27953): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)


That points to the first line of the constructor where I use BitmapFactory.decodeResource. On my Galaxy S3 I get the error when I switch to another fragment and then I come back to the fragment that displays the GLSurfaceView (onPause and onResume are called on the GLSurfaceView).


How can I avoid this problem ? I tried this solution but I lose too much quality and in rare case the bug happens anyway (probably on old phones models).


Is there something wrong how I create / store my textures ? Also do you know why I don't always get this error ? (generally I get it the second time I load the textures).



.

stackoverflow.comm

[General] Ting Discount or Ting offers code is Now Available


My friend tells me Ting now offers promotion code for new accounts.I will share the promo URLs on all members.
The Ting website will show you "you get a $25 credit to help you get started with Ting" if you sign up or your friends sign up.
Here is the two Ting promo URLS,
OR
The above URLS are the same.
Terms and Conditions
1.Ting promo code/URL is reusable and can be distributed to as many people as you like.
2.This offer is only valid for first device purchase on new accounts.
Description of Ting:
Ting is mobile phone service that makes sense: no contracts, great rates, and no-hold customer support.
Hope i can help you!



.

forum.xda-developers.com

[android help] In-App payment in amazon

android - In-App payment in amazon - Stack Overflow








Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.


















I have followed the following steps As shown in image ..steps in In AppPayment amazon but the problem is when i run the code provided in sdk as shown in image 4 when i click the button the number of clicks should be deducted but it is not. I have place the follwing values in string.xml m i right in theses steps?



amazoncheckout

com.amazon.checkout
com.amazoncheckoutconsumable
com.amazoncheckoutentitlementn
com.amazon.buttonclicker.blue_button
com.amazoncheckoutsubscription
com.amazoncheckoutsubscriptionmonthly


enter image description here


The above sku is generated by me and i also want to know the the json file shown in image three , i have downloaded that and placed in assert folder .. what is this json file for ? kind provide comment on my steps where i m wrong ... the click number is shown 5 but when i click it is not deducted why? any help will be appricated .... Thanks


















This question has an open bounty worth +50 reputation from Venkat ending in 6 days.


Looking for an answer drawing from credible and/or official sources.


i am stuck with this. please anybody help. i want to test the amazon app in my app.
















I'm going to try to explain how can you have the demo working, because, I think, that's your question, sorry if I'm wrong...



  1. Install the AmazonSDKTester.apk in your device and open it. It's inside tools folder in the SDK package. For install it you can use in terminal:


    adb install AmazonSDKTester.apk




  2. Next add your project to Eclipse:


    File > New > Project...>Android Project from Existing Code , browse the Button Clicker Demo Project in the SDK folder and Finish.




  3. Copy the amazon.sdktester.json file to SD memory. In the ButtonClicker project folder, go to assets folder and add the amazon.sdktester.json file to the SD memory. An easy way it's dragging the file to the SD folder using DDMS file explorer. Your SD folder may be different depends on device, in my Nexus S is like you can see in the image.



enter image description here


And that's it, you must have Button Clicker Demo sample fully working. When you make a purchase you can go to the AmazonSDKTester and see all your purchases. Hope it helps you and solves your problem.














Not the answer you're looking for? Browse other questions tagged or ask your own question.







default







.

stackoverflow.comm

[android help] reuse header ui design and functionality in all activities


I am working on application which have same header in all activites,in which there are some views in image views, buttons, textviews etc.


Now the The question is i want to use these header views in all the activites,but i do not want to re-code and re-design it in every activity.so is it possible to create a fragment of header views and reuse its ui and functionalities in all other activites.


  • if no,then any idea to make it reusable header?

  • if yes,then how ?

thanks for the help.!


updates in this question according to my research! i have researched and fond that it can easily acheived by using fragments.but i am still not getting that how? how can i acheive that functionality? according to this: reusable UI in android app


and this:


reusable ui with fragments


any links and code would be helpful!



.

stackoverflow.comm

[android help] how to stream videos from android device to PC


Plz can someone tell me how to stream videos from android device to PC ?



i was thinking about using the ftp protocol to share media stored on the phone but i don't know if that's easy to do ?




.

stackoverflow.comm

[android help] How to fit the images in webview from url


Now i am working on a list view with webview.in this listview webview is using for showing images.and it is from the url.now i am facing a problem that from url i am not getting the unique dimension images,some images are small and some are large,while showing this tho webview it not properly arranged.how can i properly arrange/fit the webview images.i am using the following code.



android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:id="@+id/webView"
android:layout_width="55dp"
android:layout_height="55dp"

>



WebView webView = (WebView)view.findViewById(R.id.webView);
showImageOnWebView(webView, item.thumbimage,80,80);


.

stackoverflow.comm

[android help] My Runner using a Handler is not working on android


Here's what I got so far guys, this is my app, all it does is display a digital clock and move the clock to a new part of the screen every 30 seconds, but it doesn't actually do that last part, here's the code:



public class MainActivity extends Activity {

private Runnable runnable = new Runnable(){
@Override
public void run() {
handler.sendEmptyMessage(0);
}
};
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
//change the text position here
this.postDelayed(runnable , 30000);
}
};

@Override
protected void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


TextView textView = (TextView) findViewById(R.id.digitalClock);
Random r = new Random();

Thread thread =new Thread(runnable );
thread.start();

int x = r.nextInt(350 - 100);
int y = r.nextInt(800 - 100);

textView.setX(x);
textView.setY(y);
}


I just cant seem to get this to work, been scanning the internet for about a week now. I think it's got something to do with the "New Thread" but not too sure what.



.

stackoverflow.comm

[General] Soundcloud link opens in google play


In facebook app, a friend posted a soundcloud file, when I click it, it takes me to soundcloud in the play store app. I installed it and still opens the play app. Facebook says it has no defaults set. I reset play's defaults and its still doing it.

Anyone?

Sent from my phone with the app.



.

forum.xda-developers.com

[android help] Playing mp4 video file in Android

media - Playing mp4 video file in Android - Stack Overflow








Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















I am trying to play a mp4 video file from remote url in android media player.but I am getting an error code --


Command PLAYER_PREPARE completed with an error or info PVMFErrNoResources error (1, -15)


I have searched for the error code and found that this error is returned if the resource required in processing of a request is not being available. A typical example is, a socket node connection not available for streaming.


link text


any help would be appreciated...





























i solved the problem by getting resumable video from Internet




















default







.

stackoverflow.comm

[android help] Android push Notification with Google Play

Android push Notification with Google Play - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















In my project I want to give a push notification to the user if there is an update new version on Play store. I have to notify every time the user turn on phone. Is there any way to do this? Please help me on this


Thanks in Advance..
















Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.










default






.

stackoverflow.comm

[General] Lg nitro wifi problem


my phone connects to the wifi perfectly fine but when i lock the screen it disconnects, is there a way that it can stay on while its locked so that i can continue to use messaging apps when my phone is locked? HELPPP



.

forum.xda-developers.com

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...