Okhelp.cz

Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

ADT Bundle 22.6.2 have memory leak.


AD MOB

If I trying
android-sdk_r22.6.2-windows.zip
adt-bundle-windows-x86_64-20140321.zip
and open xml layout graphic editor and xml layout file
memory continues to grow to crashes Eclipse

https://developer.android.com/sdk/index.html

I have to install old version adt-bundle-windows-x86-20131030.zip
what working fine.
I had to delete .metadata folder in workspace if I want open old version ADT

397LW NO topic_id




AD

Další témata ....(Topics)


16

float in Java example code | float-in-java-example-code


Android development
Java float is 32 bit single precision type and used when fractional precision calculation is required.

Java float je 32 bitů veliké číslo sloužící především pro přesný výsledek za desetinnou tečkou například při dělení čísel. Pro větší přesnost použíijte 64 bitový typ Double.


		// declaration and assignment of value  type float
		float x = 18.41785f;
		//print formated  value
		System.out.printf("The value of x is %.3f%n", x); // 18.418
                
                // declaring more variables in single statement
                float f1 = 12.4F, f2 = 564.5F, f3 = 14.589F;

		// float range of value
		System.out.println(Float.MIN_VALUE); // 4E-45
		System.out.println(Float.MAX_VALUE); // 4028235E38

		// is NaN  Not-a-Number
		float f = (float) Math.sqrt(-15);
		boolean bNaN = Float.isNaN(f);
		System.out.print(bNaN); // true
		
                // check if a string is a valid number in Java example
                // convert string to float Java example
		String sF = "12.8";
		float fParse = Float.parseFloat(sF);

	       // convert strings to numbers
	      String sFl = "15.48";
	      float fFromString = (Float.valueOf(sFl)).floatValue();

// float to string in Java example code
Float fObj = new Float(68.5);
String str = fObj.toString();
// else 
Float fS = 11.6f;
String sFloat = fS.toString();

              // compare two float variables
	      Float fComp1 = 4.3f;
	      if(fComp1.equals(4.3f))
	  		System.out.print("true");

	    // compares the two specified float values in Java example
	    int i =	Float.compare(11.5f, 11.7f); // -1 first < second
	    // 0 first == second
	    // 1 first > second
	    System.out.print(i);


71

For cycle loop in Java example | for-cycle-loop-in-java-example


Cycle for in Java example

public class MainClass {
	public static void main(String[] arg) {
		String[] arrayOfString = { "Hello", "people", "hello", "world!" };

		for (int i = 0; // start position , first cycle i == 0
                      i < arrayOfString.length; // if i < 4 (length of array) do loop
                       i++ // incrementation after cycle
                       ){
			System.out.println(arrayOfString[i]); 
                       // i++ incrementation
		}
	}
}

223

Disable enable internet connection in Android Emulator | disable-enable-internet-connection-in-android-emulator


If you try function for checking internet connection you can disable internet on the emulator:
Settings - Wireless and networks - Mobile networks - Data enabled (checked - unchecked )


 public boolean isNetworkAvailable() {
        ConnectivityManager cm = (ConnectivityManager) 
          getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = cm.getActiveNetworkInfo();
        if (networkInfo != null && networkInfo.isConnected()) {
            return true;
        }
        return false;
    }     





294

Get Bitmap Size Get Free Memory Exception Android | get-bitmap-size-get-free-memory-exception-android


Bitmap size calculation:
bmpHeight * bmpWidth
For example:
Resolution of image 1024x860 = 880 640 pixels
If every pixel get 4 byte of memory:
880 640x4= 3 522 560 (3.5MB)

Get bitmap size without allocation of memory:

   	BitmapFactory.Options options = new BitmapFactory.Options();
        // If set to true, the decoder will return null (no bitmap), but the out... fields will still
        // be set, allowing the caller to query the bitmap without having to allocate the memory for its pixels. 
    	options.inJustDecodeBounds = true; 
    	BitmapFactory.decodeResource(getResources(), R.drawable.my_image, options);
    	int imageHeight = options.outHeight; // 1024
    	int imageWidth = options.outWidth; // 860
    	String imageType = options.outMimeType; // .jpg .png .gif
 


Get Memory size:
Make your bitmap not bigger as maxMemory size
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);

    float density = getResources().getDisplayMetrics().density;

    Debug.MemoryInfo memoryInfo = new Debug.MemoryInfo();
    Debug.getMemoryInfo(memoryInfo);
    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    final int freeMemory = (int) (Runtime.getRuntime().freeMemory() / 1024);
    String memMessage = String.format(
        "Free=%d kB,

MaxMem=%d kB,
Memory: Pss=%.2f MB, Private=%.2f MB, Shared=%.2f MB", freeMemory, maxMemory, memoryInfo.getTotalPss() / 1024.0, memoryInfo.getTotalPrivateDirty() / 1024.0, memoryInfo.getTotalSharedDirty() / 1024.0); ((TextView)findViewById(R.id.textViewInfo)).setText(memMessage );
390

Android runtime change switch Activity theme | android-runtime-change-switch-activity-theme



static boolean mbThemeLight = false;

 @Override
    public void onCreate(Bundle savedInstanceState) {
         if(mbThemeLight)
        setTheme(android.R.style.Theme_Light);
        super.onCreate(savedInstanceState);
        // bla bla bla..........
    }

private void switchTheme(){
 mbThemeLight = true;
 this.recreate();
}


Editace: 2014-04-03 08:49:37
Počet článků v kategorii: 397
Url:adt-bundle-22-6-2-have-memory-leak

AD
11 Share
Share
Tweet