Learn Android for Free,download top android appllications

Tuesday, March 3, 2015

Custom ImageView Circular imageview

Circular imageview android

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;

import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;

public class RoundImageView extends ImageView {

public RoundImageView(Context context) {

public RoundImageView(Context context, AttributeSet attrs) {
super(context, attrs);

public RoundImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);

protected void onDraw(Canvas canvas) {
BitmapDrawable drawable = (BitmapDrawable) getDrawable();

if (drawable == null) {

if (getWidth() == 0 || getHeight() == 0) {

Bitmap fullSizeBitmap = drawable.getBitmap();

int scaledWidth = getMeasuredWidth();
int scaledHeight = getMeasuredHeight();

Bitmap mScaledBitmap;
if (scaledWidth == fullSizeBitmap.getWidth()
&& scaledHeight == fullSizeBitmap.getHeight()) {
mScaledBitmap = fullSizeBitmap;
} else {
mScaledBitmap = Bitmap.createScaledBitmap(fullSizeBitmap,
scaledWidth, scaledHeight, true /* filter */);

Bitmap circleBitmap = getCircledBitmap(mScaledBitmap);

canvas.drawBitmap(circleBitmap, 0, 0, null);


public Bitmap getRoundedCornerBitmap(Context context, Bitmap input,
int pixels, int w, int h, boolean squareTL, boolean squareTR,
boolean squareBL, boolean squareBR) {

Bitmap output = Bitmap.createBitmap(w, h, Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final float densityMultiplier = context.getResources()

final int color = 0xff424242;

final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, w, h);
final RectF rectF = new RectF(rect);

// make sure that our rounded corner is scaled appropriately
final float roundPx = pixels * densityMultiplier;

canvas.drawARGB(0, 0, 0, 0);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

// draw rectangles over the corners we want to be square
if (squareTL) {
canvas.drawRect(0, 0, w / 2, h / 2, paint);
if (squareTR) {
canvas.drawRect(w / 2, 0, w, h / 2, paint);
if (squareBL) {
canvas.drawRect(0, h / 2, w / 2, h, paint);
if (squareBR) {
canvas.drawRect(w / 2, h / 2, w, h, paint);

paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(input, 0, 0, paint);

return output;

Bitmap getCircledBitmap(Bitmap bitmap) {

Bitmap result = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Bitmap.Config.ARGB_8888);

Canvas canvas = new Canvas(result);

int color = Color.BLUE;
Paint paint = new Paint();
Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

canvas.drawARGB(0, 0, 0, 0);
canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
bitmap.getHeight() / 2, paint);

paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);

return result;


Admob integration into Android application (Google advertisements )

    In Activity file add the below code

AdView mAdView = (AdView) rootView.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();

Declare in your xml layout file wherever you want to place advertisement

        ads:adUnitId="@string/banner_ad_unit_id" >


Manifest declaration :

 <!--Include the AdActivity configChanges and theme. -->
        <activity android:name="com.google.android.gms.ads.AdActivity"

            android:theme="@android:style/Theme.Translucent" />

in strings.xml
declare banner ad unit id
<string name="banner_ad_unit_id">ca-app-pub-8076328522522776/3847247228</string>

Now ready to see ads in the application.

Friday, January 31, 2014

Show Notification Banner in IOS

If the ios app is running in the background, it won't show the notification banner, this is by design. But if you want to show the custom banner in the status bar whether the application in foreground or in the background, you can show the  banner.

  UILocalNotification *localNotification = [[UILocalNotification alloc] init];
        localNotification.userInfo = userInfo;
        localNotification.soundName = UILocalNotificationDefaultSoundName;
        localNotification.alertBody = @"test";
        localNotification.fireDate = [NSDate date];
        [[UIApplication sharedApplication] scheduleLocalNotification:localNotification];

Friday, January 24, 2014

This error occurred during compiling... phone gap push notification

5:12 AM Posted by Srinivas Nidadavolu No comments
Undefined symbols for architecture armv7s:
  "_OBJC_METACLASS_$_CDVPlugin", referenced from:
      _OBJC_METACLASS_$_PushNotification in PushNotification-F9383623544E8079.o
  "_OBJC_CLASS_$_CDVPluginResult", referenced from:
      objc-class-ref in PushNotification-F9383623544E8079.o
  "_OBJC_METACLASS_$_CDVViewController", referenced from:
      _OBJC_METACLASS_$_MainViewController in MainViewController.o
  "_OBJC_CLASS_$_CDVPlugin", referenced from:
      _OBJC_CLASS_$_PushNotification in PushNotification-F9383623544E8079.o
  "_OBJC_CLASS_$_CDVViewController", referenced from:
      _OBJC_CLASS_$_MainViewController in MainViewController.o
ld: symbol(s) not found for architecture armv7s

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Tuesday, October 8, 2013

Transparent Activity Android

Use this style   , declare in manifest 
<?xml version="1.0" encoding="utf-8"?>
  <style name="Theme.Transparent" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:backgroundDimEnabled">false</item>
    <item name="android:windowIsFloating">true</item> 
    <item name="android:windowBackground">@android:color/transparent</item> 
or use 
Download sample code here

Friday, September 27, 2013

What is Hadoop?

11:59 AM Posted by Srinivas Nidadavolu , , 1 comment
Hadoop is an open source software framework which allows distributed processing of large datasets across clusters of computers using simple programming model.

Hadoop is a platform designed to solve where we have large data.It is designed from single server to thousands of machines and each will offer computation and storage.

Hadoop library itself detect the hardware failures.

The Hadoop project includes the following modules:

1. Hadoop common
2. Hadoop Distributed File System
3. Hadoop YARN
4. Hadoop MapReduce