Sunday, 29 July 2012

How To download an image and save to the memory card


/First create a new URL object 
URL url = new URL("http://www.google.co.uk/logos/holiday09_2.gif")
//Next create a file, the example below will save to the SDCARD using JPEG
// format
File file = new File("/sdcard/example.jpg");
//Next create a Bitmap object and download the image to bitmap
Bitmap bitmap = BitmapFactory.decodeStream(url.openStream());
//Finally compress the bitmap, saving to the file previously created
bitmap.compress(CompressFormat.JPEG, 100, new FileOutputStream(file));

Don't forget to add the Internet permission to your manifest:
 android:name="android.permission.INTERNET" />

Mohammad Abu Hmead

Saturday, 23 June 2012

I updated the java and eclipse does not work



I updated the JRE today 23.06.2012, and after that the eclipse does not work, when I double click on eclipse it makes like the camera flash.

What is the solution?

Here is it

I just added this line to the eclipse.ini file
 -vm
C:\Program Files\Java\jdk1.7.0_03\bin\javaw.exe
And it is now running successfully.
Mohammad Abu Hmead

Sunday, 20 May 2012

Install apk on android emulator

To install android application (.apk) on an emulator follow these steps:

1- run the target emulator
2- copy the .apk file into platform-tools folder
3- cd into platform-tools folder
ex: E:\>cd \Android Full Development Platform (SDK+Eclipse)\android-sdk-windows\platform-tools
4- adb install theApkFileName.apk

if you launched more than one emulator, use the following code

adb -s emulator-5556 install  theApkFileName.apk


Hint: make sure adb.exe in the platform-tools folder


Mohammad Abu Hmead

Thursday, 17 May 2012

Reset Identity column in SQL Server


Just use the following code and run it, your identity columns will be reset to the value you use 

DBCC CHECKIDENT('TableName', RESEED, 0)


Mohammad Abu Hmead

Wednesday, 16 May 2012

Android Shape



xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <corners android:radius="40dp" />
    <padding
        android:left="20dp"
        android:right="20dp" />
shape>


<gradient
        android:centerColor="#FF0000"
        android:endColor="#00FF00"
        android:startColor="#0000FF"
        android:type="sweep"
        android:useLevel="false" />




<gradient       
        android:centerColor="#FF0000"
        android:endColor="#00FF00"
        android:gradientRadius="150"
        android:startColor="#0000FF"
        android:type="radial"
        android:useLevel="false" />



<gradient
        android:centerColor="#FF0000"
        android:endColor="#00FF00"
        android:startColor="#0000FF"
        android:type="linear"
        android:useLevel="false" />




<gradient
        android:angle="135"
        android:centerColor="#FF0000"
        android:endColor="#00FF00"
        android:gradientRadius="20"
        android:startColor="#0000FF"
        android:type="linear"
        android:useLevel="false" />


Gradient Angles (0,45,90,180,135,225,270)



<stroke
        android:dashGap="5dp"
        android:dashWidth="10dp"
        android:width="10dp"
        android:color="#ABCDEF" >
    stroke>




Mohammad Abu Hmead

Wednesday, 2 May 2012

Image get be zoomed in Android

I had a problem, when I'm using a list of icons and texts in android app, when i press on the list item, the icon must be shown in another activity with size larger than the current(on the list item), when I press back to back to the list activity, i saw the image get zoomed. I solved the issue by creating new object from the current Drawable via the code bellow
Bitmap bitmap = ((BitmapDrawable)listItemIconDrawableObject).getBitmap();   
BitmapDrawable d = new BitmapDrawable(bitmap);
//use d whenever you want


Mohammad Abu Hmead

Tuesday, 3 April 2012

Android Byte Array to Drawble

You can use this method to convert a byte array (which is in the original an image) to Android Drawable


public Drawable getDrwableFromBytes(byte[] imageBytes) {

if (imageBytes != null)
return new BitmapDrawable(BitmapFactory.decodeByteArray(imageBytes,
0, imageBytes.length));
else
return null;
}


Mohammad Abu Hmead