Thursday, May 19, 2016

Android Studio Java Out of Memory Error




Recently i was coding in android studio and found that when i tried to import an image into an app that i built that the app would crash with an out of memory error.  So i did some research on the issue and ended up on github with some helpful tutorials.

This tip is helpful but could prove problematic.
Got a quick Solution
<application
     android:largeHeap="true" >
put into appplication tag in manifest file.
So i tried this one.
 public static Bitmap decodeFile(File f,int WIDTH,int HIGHT){
 try {
     //Decode image size
     BitmapFactory.Options o = new BitmapFactory.Options();
     o.inJustDecodeBounds = true;
     BitmapFactory.decodeStream(new FileInputStream(f),null,o);

     //The new size we want to scale to
     final int REQUIRED_WIDTH=WIDTH;
     final int REQUIRED_HIGHT=HIGHT;
     //Find the correct scale value. It should be the power of 2.
     int scale=1;
     while(o.outWidth/scale/2>=REQUIRED_WIDTH && o.outHeight/scale/2>=REQUIRED_HIGHT)
         scale*=2;

     //Decode with inSampleSize
     BitmapFactory.Options o2 = new BitmapFactory.Options();
     o2.inSampleSize=scale;
     return BitmapFactory.decodeStream(new FileInputStream(f), null, o2);
 } catch (FileNotFoundException e) {}
 return null;
}
Which would work if i knew how to use decodeFile in my code.
Solution:
Finally i was led to this link Android Developer Site Which had a Android program that i downloaded and studied to find the solution.  If you are like me and find this error just go to the developer site and study the code.  
Thanks for reading.

Is Vaping Safe?




In case you didn't know Vaping is the smoking of vaporizers.  Vaporizers are devices that people use to vaporize and inhale all types of different liquid chemicals.  Chemicals from weed to synthetic cigarettes and tasty great smelling liquids that do nothing.

The vaporizers are battery powered and heat up the liquids in them with a resistance coil turning the liquid into vapor.

This practice is becoming more and more popular for people who are trying to quit smoking.

However the question has come up time and time again, is vaping safe?

In a study written about in Science News. scientists discovered that e-cigarettes (also vaporizers) deliver more nano-particles into the body than regular cigarettes.  These nano-particles can inflame the lungs and exacerbate things like heart disease and stroke.

Another concern was brought to light when a scientist ran a study to see if vapors from e-cigs had an impact on bacteria.  They found that bacteria exposed to vapors with nicotine in it would secrete a thicker ectoplasm/biofilm to protect the bacteria making it harder for antibiotics to kill it.

The bottom line is that vaping is safer than smoking. For the short run.  However because of the known issues that vaping can make worse its best to use vaping as a way to stop smoking and nothing else.  Unless you want to be part of a case study on MRSA (Methicillin-resistant Staphylococcus aureus ).

As always thanks for reading and I hope I answered some questions.  

If you liked this article check out another one I wrote on modern day adults.

http://www.calebsapps.com/2016/07/lost-as-adult.html

You can find the whole article I got most of my info from here Science News.


Featured Post

Washington State Poisonous Toad

The Western Toad pictured above can be green or brown and is always covered in warts.  (This is the frog he tried to eat) One w...