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


AD MOB

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




AD

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


98

Activity Lifecycle if button Home pressed Android example | activity-lifecycle-if-button-home-pressed-android-example


If on Android emulator home button pressed.

// button home presssed
19:37:06.727: INFO/ActivityManager(60): Starting: 
Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] 
flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher } from pid 60

19:37:06.807: INFO/onSaveInstanceState(339): onSaveInstanceState()
19:37:06.848: INFO/onPause(339): onPause()
19:37:07.968: INFO/onStop(339): onStop()


Diagram of Activity lifecycle if button HOME pressed

life_cycle_button_home_pressed
262

Font Family change on View dynamically Android Example | font-family-change-on-view-android-example


TypeFace, setTypeface, font, font family, array of String, Button create dynamically

@Override
protected void onStart() {
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
  48,
  55
);	
Typeface typeFace = Typeface.MONOSPACE;	
String [] ar = {"A","B","C","D","E","F","G","H","J","K"};
for (int i = 0; i < ar.length; i++) {
Button buttonView = new Button(this);
buttonView.setText(Html.fromHtml("<b>"+ar[i]+"</b>"));
buttonView.setTextColor(Color.BLUE);
buttonView.setTextSize(27.f);
buttonView.setTypeface(typeFace,Typeface.BOLD);
buttonView.setOnClickListener(mThisButtonListener);
if(i%2==0)
	mLayoutButtons.addView(buttonView, p);
else
	mLayoutButtonsNextRow.addView(buttonView, p);
	
_listOfButtons.add(buttonView);
}

	super.onStart();
}

//////// xml file
<TextView
    android:id="@+id/text01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="20dp"
    android:fontFamily="Arial"
 />
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;
    }     





148

Crop cropped cut bitmap image pictures Android example | crop-cropped-cut-bitmap-image-pictures-android-example


Cut, shear, clip, snip, crop a bitmap, picture, image Android example

public class ApokusActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(new SampleView(this));
	}

	private static class SampleView extends View {

		// CONSTRUCTOR
		public SampleView(Context context) {
			super(context);
			setFocusable(true);

		}

		@Override
		protected void onDraw(Canvas canvas) {
			Paint paint = new Paint();

			canvas.drawColor(Color.YELLOW);


			// you need to insert a image flower_blue into res/drawable folder
			paint.setFilterBitmap(true);
			Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
					R.drawable.flower_blue);

			Bitmap croppedBmp = Bitmap.createBitmap(bitmapOrg, 0, 0,
					bitmapOrg.getWidth() / 2, bitmapOrg.getHeight());
			int h = bitmapOrg.getHeight();
			canvas.drawBitmap(bitmapOrg, 10, 10, paint);
			canvas.drawBitmap(croppedBmp, 10, 10 + h + 10, paint);

		}

	}
}



crop bitmap android
201

Samsung Galaxy Y (S5360) | samsung-galaxy-y-s5360






























Brand Samsung
Model (codename) Galaxy Y (S5360)
Cena, včetně DPH 2400 / 06.2012
Display size (v palcích) 3
Display-resolution 240x320
Dotek-typ kapacitní
CPU typ BCM21553
CPU MHz 832
CPU core
L2 cache ?
RAM 256
ROM 512
GPU VideoCore IV
NenaMark2 Benchmark 12
GPU-GLBenchmark
Baterie mAh 1200
Foto MPx 2
Autofocus ne
Video
Official Android ICS Android OS v 2.3
CyanogenMod support
Dotek-prstů-max
Display-ppi 133
Display-retina 41%
Network čîtyřpásmový GSM 850/900/1800/1900 MHz , HSDPA 2100 MHz
Connectivity Bluetooth v2.0 plus EDR plus support A2DP, USB host
Pozn. CPU ARMv6, GPU 20MT/s OpenGL ES 2.0


samsung galaxy y smartphone


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

AD
11 Share
Share
Tweet