Android development with simple sample programs and tutorials from android First program. Learn android easily.
Friday, October 21, 2011
Android Save Image to Media Provider
Android Save Image to Media Provider
Thursday, October 20, 2011
Bitmap out of memory
Tuesday, October 18, 2011
Android Compress Image File
f = new FileInputStream("path");
scale=2;
BitmapFactory.Options op=new BitmapFactory.Options();
op.inSampleSize=scale;
Bitmap bitmap=BitmapFactory.decodeStream(f,null,op);
Create Thumbnails of Image
Create Thumbnails of image/Compress Imgage .
This program for to display Thumbnails of images store in sdcard or any other location.
BitmapFactory.Options op=new BitmapFactory.Options();
InputStream f = null;
try {
f = new FileInputStream(files[position].getAbsolutePath());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
final int REQUIRED_SIZE=1024;
int width_tmp=op.outWidth, height_tmp=op.outHeight;
int scale=1;
while(true){
if(width_tmp/2
break;
width_tmp/=2;
height_tmp/=2;
scale*=2;
}
op.inSampleSize=scale;
Bitmap b2; b2=Bitmap.createScaledBitmap(BitmapFactory.decodeFile(files[position].getAbsolutePath(),op),50, 50,true);
imageView.setImageBitmap(b2);
Here while loop is used because image file can me more than 1 mb in size so there may be cresh or it can take more time to set in imgageview, so we reducing scale of that image.
Saturday, October 15, 2011
Android Introduction and Architecture(Part1)
What is Android?
Features
- Application framework enabling reuse and replacement of components
- Dalvik virtual machine optimized for mobile devices
- Integrated browser based on the open source WebKit engine
- Optimized graphics powered by a custom 2D graphics library; 3D graphics based on the OpenGL ES 1.0 specification (hardware acceleration optional)
- SQLite for structured data storage
- Media support for common audio, video, and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF)
- GSM Telephony (hardware dependent)
- Bluetooth, EDGE, 3G, and WiFi (hardware dependent)
- Camera, GPS, compass, and accelerometer (hardware dependent)
- Rich development environment including a device emulator, tools for debugging, memory and performance profiling, and a plugin for the Ec
Android Architecture
Applications
Application Framework
- A rich and extensible set of Views that can be used to build an application, including lists, grids, text boxes, buttons, and even an embeddable web browser
- Content Providers that enable applications to access data from other applications (such as Contacts), or to share their own data
- A Resource Manager, providing access to non-code resources such as localized strings, graphics, and layout files
- A
Notification Manager
that enables all applications to display custom alerts in the status bar - An
Activity Manager
that manages the lifecycle of applications and provides a common navigation backstack
Libraries
- System C library - a BSD-derived implementation of the standard C system library (libc), tuned for embedded Linux-based devices
- Media Libraries - based on PacketVideo's OpenCORE; the libraries support playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG
- Surface Manager - manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications
- LibWebCore - a modern web browser engine which powers both the Android browser and an embeddable web view
- SGL - the underlying 2D graphics engine
- 3D libraries - an implementation based on OpenGL ES 1.0 APIs; the libraries use either hardware 3D acceleration (where available) or the included, highly optimized 3D software rasterizer
- FreeType - bitmap and vector font rendering
- SQLite - a powerful and lightweight relational database engine available to all applications
Android Runtime
Linux Kernel
Friday, October 14, 2011
Android Check the Availability of Network Example
SOURCE CODE [main.xml] is
Note:
Don’t forget to add
<manifest xlmns:android...>
...
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
The OUTPUT will be
Android - Search in Custom ListView Example
SOURCE CODE [main.xml] is
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText android:id="@+id/EditText01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="Search">
</EditText>
<ListView android:id="@+id/ListView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</ListView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:gravity="left|center"
android:layout_width="fill_parent"
android:paddingBottom="5px"
android:background="#fff200"
android:paddingTop="5px"
android:paddingLeft="5px">
<ImageView android:id="@+id/ImageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</ImageView>
<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20px"
android:textStyle="bold"
android:layout_marginLeft="10px"
android:textColor="#0099CC">
</TextView>
</LinearLayout>