Kamis, 20 Mei 2010

Create a Circle in Andrind

In this Ariticle helps to create a circle in andriod using

Create a Customized View Class
public class Ball extends View {}

Override the onDraw()
protected void onDraw(Canvas canvas) { }

Create Paint Object for draw the circle
mPaints1 = new Paint();
        mPaints2 = new Paint();
        mPaints1.setAntiAlias(true);
        mPaints1.setStyle(Paint.Style.FILL);

        mPaints2 = new Paint(mPaints1);
        mPaints2.setColor(Color.BLUE);
        mBigOval = new RectF(40, 10, 280, 250);

Draw Circle using drawArc
canvas.drawArc(oval, mStart, mSweep, useCenter, paint);


SourceCode

public class Ball extends View {

    private Paint mPaints2;
    private Paint mPaints1;
    private RectF mBigOval;
    private float mStart, mSweep;
    private int mBigIndex;

    public Ball(Context context) {
        super(context);

        mPaints1 = new Paint();
        mPaints2 = new Paint();
        mPaints1.setAntiAlias(true);
        mPaints1.setStyle(Paint.Style.FILL);

        mPaints2 = new Paint(mPaints1);
        mPaints2.setColor(Color.BLUE);
        mBigOval = new RectF(40, 10, 280, 250);
    }

    private void drawArcs(Canvas canvas, RectF oval, boolean useCenter,
            Paint paint) {
        canvas.drawArc(oval, mStart, mSweep, useCenter, paint);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.drawColor(Color.WHITE);
        drawArcs(canvas, mBigOval, true, mPaints2);
        mSweep += 2;
        if (mSweep > 360) {
            mStart += 10;
            if (mStart >= 360) {
                mStart -= 360;
            }
            mBigIndex = (mBigIndex + 1);
        }
        invalidate();
    }
}


Senin, 10 Mei 2010

Steps to create Andriod Widget

In this article will help us to create customized Widget.

1. Create a Layout for Widget
2. Create Widget Class
3. Adding the Widget Provider Info Metadata
4. Register the Widget in Androidmanifest.xml
5. Add the Widget in your homepage


Create a Layout for Widget
<?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" android:background="@drawable/widget_bg">
    <Button android:text="Click" android:id="@+id/Button01"
        android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>

    <TextView android:id="@+id/text" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:text="@string/hello"
        android:gravity="center" android:textColor="@android:color/black" />
</LinearLayout>

Create Widget Class
public class Widget extends AppWidgetProvider {
    private SimpleDateFormat formatter = new SimpleDateFormat(
            "EEE, d MMM yyyy\nHH:mm:ss.SSS");

    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager,
            int[] appWidgetIds) {
       
        String now = formatter.format(new Date());

        Intent intent = new Intent(context, MainActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,intent, 0);

        RemoteViews updateViews = new RemoteViews(context.getPackageName(),R.layout.main);
        updateViews.setTextViewText(R.id.text, now);
        appWidgetManager.updateAppWidget(appWidgetIds, updateViews);

       
        RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.main);
        views.setOnClickPendingIntent(R.id.Button01, pendingIntent);
        appWidgetManager.updateAppWidget(appWidgetIds, views);

        super.onUpdate(context, appWidgetManager, appWidgetIds);

    }
}

Adding the Widget Provider Info Metadata

    <?xml version="1.0" encoding="utf-8"?>
    <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
        android:minWidth="166dip" android:minHeight="72dip" android:updatePeriodMillis="60000" android:initialLayout="@layout/main" />


Register the Widget in Androidmanifest.xml

    <receiver android:label="@string/widget_name" android:name=".Widget">       
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
        </intent-filter>       
        <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget" />       
    </receiver>

Add the Widget in your homepage
    Click Menu -> Add -> Widget -> YOUR WIDGET





Minggu, 09 Mei 2010

Andriond Interview Question -1

Brief about the Android?
Andriod is a Operating System for device
It was initially developed by Android Inc., a firm later purchased by Google, and lately by the Open Handset Alliance.
It allows developers to write managed code in the Java language, controlling the device via Google-developed Java libraries.

Architecture of Android :
1. Linux Kernal [ 2.6 Kernal - security, memory management, process management, network stack, and driver model]
2. Native Libraries [SQLite, WEBKit, OpenGL,..]
3. Runtime + Dalvik VM [.dex format, Lightweight VM, Efficient Dalvik Bytecode]
4. Application Framework [Activity Manager, Content Manager, Location Manager, ]
5. Application [ System Apps and Your Apps]

Refer : http://about-android.blogspot.com/2009/11/architecture-of-android-1.html


What are the basic Components in Android?
Activities - An activity presents a visual user interface for one focused endeavor the user can undertake.
Services - A service doesn't have a visual user interface, but rather runs in the background for an indefinite period of time.
Broadcast receivers - A broadcast receiver is a component that does nothing but receive and react to broadcast announcements.
Content providers - A content provider makes a specific set of the application's data available to other applications.

http://about-android.blogspot.com/2009/11/application-fundamentals.html



what are the versions are avilable in android?
Version : 1.5 - Cupecake
Linux Version : 2.6.27
Offical release On : April 30th 2009
Main Feature :
* Ability to record and watch videos with the camcorder mode
* Uploading videos to YouTube and pictures to Picasa directly from the phone
* A new soft keyboard with an "Autocomplete" feature
* Bluetooth A2DP support and ability to automatically connect to a Bluetooth headset within a certain distance
* New widgets and folders that can populate the Home screens
* Animations between screens
* Expanded ability of Copy and paste to include web pages

Version : 1.6 - Donut
Linux Version : 2.6.29
Offical release On : April 30th 2009
Main Features :
* An improved Android Market experience.
* An integrated camera, camcorder, and gallery interface.
* Gallery now enables users to select multiple photos for deletion.
* Updated Voice Search, with faster response and deeper integration with native applications, including the ability to dial contacts.
* Updated search experience to allow searching bookmarks, history, contacts, and the web from the home screen.
* Updated Technology support for CDMA/EVDO, 802.1x, VPN, Gestures, and a Text-to-speech engine.
* Support for WVGA resolutions.
* Speed improvements for searching & the camera.[35]

Version : 2.0 & 2.1- Eclair
Linux Version : 2.6.29
Offical release On : October 26th 2009
Main Features :
* Optimized hardware speed
* Support for more screen sizes and resolutions
* Revamped UI
* New browser UI and HTML5 support
* New contact lists
* Better white/black ratio for backgrounds
* Improved Google Maps 3.1.2
* Microsoft Exchange support
* Built in flash support for Camera
* Digital Zoom
* MotionEvent class enhanced to track multi-touch events[41]
* Improved virtual keyboard
* Bluetooth 2.1
* Live Wallpapers

what is the folder structure of android?
1. src - It contain the java code
2. Resource - It contain the all resource with different floder
drawable - Icon
raw - Sounds
menu - Menu
values - Project Properties
layout - User interface Screens
3. gen - It contains the R.java file. You could not edit R.java manually. This have been generated automatically by understanding resource files etc.
4. AndroidManifest -It contains the Project properties
5. Android lib.

Refer :
http://about-android.blogspot.com/2009/11/application-fundamentals.html

what are the api available in the Android?
Activity Manager, WindowManager, Location Manager, View System, Notification Manager, Telephonic Manager, Package Manager,
Resource Manager,