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.

Copy save Bitmap Image Pictures Android example


Copy file to another

        File path = Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_PICTURES);
        File file = new File(path, "MyPicture.jpg");
           // the Pictures directory exists? 
            path.mkdirs();
            InputStream is = getResources().openRawResource(R.drawable.flower_blue);
            OutputStream os = new FileOutputStream(file);
            byte[] data = new byte[is.available()];
            is.read(data);
            os.write(data);
            is.close();
            os.close();


Copy and compress file

Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
					R.drawable.flower_blue);

try {
	 FileOutputStream out = new FileOutputStream("new_bitmap.jpg");
		bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 90, out);
} catch (Exception e) {
	e.printStackTrace();
	Log.e("saveBitmap", e.getMessage());
} 

397LW NO topic_id



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


34

How get Android SDK location on PC with Eclipse | how-get-android-sdk-location-on-pc-with-eclipse


How get Android SDK location - PATH on PC from Eclipse tutorial.


  1. Open dialog from menu Window -> AVD and SDK manager

  2. In dialog select Available packages

  3. On top of dialog will displayed similar path: SKD Location: C:\PROGRA~1\Android\android-sdk-windows\



277

SD card SDcard get external storage directory Android | sd-card-get-external-storage-directory-android


Environment.getExternalStorageDirectory()+ File.separator


Boolean canWrite =	Environment.getExternalStorageDirectory().canWrite() ;
if(canWrite){
File f = new File(Environment.getExternalStorageDirectory()
                        + File.separator + "my_image.jpg")
f.createNewFile();
}else{

}

AndroidManifest.xml
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
17

double in Java example for Android development | double-in-java-example-for-android-development


Java double is 64 bit double precision type used when fractional
precision calculation is required.

Java double je datový typ (reálné číslo) o velikosti 64 bitů. Používá se například pro přesný výsledek po dělení za desetinnou tečkou. Pokud nepotřebuje tak veliké číslo použijte raději typ float, šetříte tím paměť mobilního telefonu.


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

		// double range of value
		System.out.println(Double.MIN_VALUE); // 4.9E-324
		System.out.println(Double.MAX_VALUE); // 1.7976931348623157E308

		// is NaN  Not-a-Number
		double f = (double) Math.sqrt(-15);
		boolean bNaN = Double.isNaN(f);
		System.out.print(bNaN); // true
		
                // check if a string is a valid number in Java example
                // convert string to double Java example
		String sD = "12.8";
		double dParse = Double.parseDouble(sD);

	       // convert strings to numbers
	      String sDl = "15.48";
	      double dFromString = (Double.valueOf(sDl)).doubleValue();

// format double, float or long value to string
	DecimalFormat formatter = new DecimalFormat(".##");
	String s = formatter.format(-.5678);             // -0.57
// .###  -0.568
// .#### -0.5678
// .000000  -.567800

// -123.456
// .##  -123.46
// #.##  -123.46

// #E0  -.1E3
// ##E0  -1.2E2
//###E0  -123E0

// double to string in Java example code
Double dObj = new Double(68.5);
String str = dObj.toString();
// else 
Double dS = 11.6;
String sdouble = dS.toString();

// compare two double variables
	      Double dComp1 = 4.3;
	      if(dComp1.equals(4.3))
	  		System.out.print("true");

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


320

Admob ad not visible on Android Emulator | admob-ad-not-visible-on-android-emulator


Try this solution:
  				
AdView adView = new AdView(getApplicationContext());//in menu inflater getActivity()
adView.setAdUnitId("ca-app-pub-87***yourNumber");
adView.setAdSize(AdSize.BANNER); 					
LinearLayout linLay = (LinearLayout)findViewById(R.id.idReklamaLayout);
// Add the adView to it
linLay.addView(adView);
// Initiate a generic request to load it with an ad
if(Build.MANUFACTURER.equals("unknown")) {
// Emulator
AdRequest.Builder.addTestDevice("B3EEABB8EE11C2BE770B684D95219ECB"); // to get test ads on this device.
AdRequest adRequest = new AdRequest.Builder()
 .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)        // All emulators
 .addTestDevice("B3EEABB8EE11C2BE770B684D95219ECB")  // Emulator id you will get in the LogCat verbose
 .build();
			
adView.loadAd(adRequest);
	  			/* */
}else {
 // Not Emulator
// Initiate a generic request to load it with an ad
AdRequest adRequest = new AdRequest.Builder().build();   
adView.loadAd(adRequest);/**/
}


99

Essential Eclipse Shortcuts with pictures | essential-eclipse-shortcuts-with-pictures


Eclipse Navigation Shortcuts.

Keyboard_shortcuts_(3.0).pdf
Ctrl+1 Quick fix problem
eclipse-ctrl-1



Ctrl+O Quick Outline
eclipse-ctrl-o



Ctrl+Shift+G Find references in workspace
Ctrl+Shift+U Find all references in file
eclipse-ctrl-shift-u




Ctrl+Shift+T Find Java Typ

[caption id="attachment_1214" align="alignleft" width="150" caption="eclipse-ctrl-shift-t"][/caption]


Ctrl+Shift+R Find Resource



Ctrl+E Open Editor Drop-Down
Ctrl+Space Content Assist
eclipse-ctrl-space


Ctrl+Shift+Space Context Information

eclipse-ctrl-shift-space


F3 Open Declaration of variable
F4 Open Type Hierarchy
Ctrl+H Open Search Dialog
Alt+Shift+R Rename - Refactoring
Alt+Shift+M Extract Method
Alt+Shift+L Extract Local Variable

Alt Shift Up Expand selection to enclosing element
Alt Shift Right Expand selection to next element
Alt Shift Left Expand selection to previous element
Alt Shift Down Restore previous selection

Breakpoints Shift+Alt+Q B
Cheat Sheets Shift+Alt+Q H
Console Shift+Alt+Q C
Java Declaration Shift+Alt+Q D
Java Package Explorer Shift+Alt+Q P
Java Type Hierarchy Shift+Alt+Q T
Javadoc Shift+Alt+Q J
Search Shift+Alt+Q S
Show View (View: Outline)Shift+Alt+Q O
Show View (View: Problems)Shift+Alt+Q X
Synchronize Shift+Alt+Q Y
Variables Shift+Alt+Q V



Editace: 2011-11-17 21:42:23
Počet článků v kategorii: 397
Url:save-bitmap-image-android-example
Share
Share
Tweet