Author Archives: Mustafij

  • 0

Transformation of Sentence

ic_launcher

Transformation of Sentence

This is an excelent Android App

 This App will cover:
Transformation of sentence from class- Six, Seven, JSC, SSC, HSC, Degre, Honers, University Admission, Job admission, and BCS.
Table of Contents:
1. Affirmative to Negative.
2. Assertive to Interrogative.
3. Assertive to Imperative.
4. Assertive to Exclamatory.
5. Exclamatory to Assertive.
6. Positive-Comparative-Superlative.
7. Simple-Compound-Complex.
8. 52 Exercises with Answer.
This App will also cover for Class Six to Eight 5 Marks in the Exam.
Class Nine to Inter 10 marks.
This App also help the teachers to teach their Students in inductive method.
The students can also find the App very easy and helpful to learn Transformation of Sentence.
Thank you.


  • 0

Android button shape

Category : Uncategorized

To have better look of your buttons, you might want to change the buttons’ shape. In Android, it is easy to achieve this goal. You have to define a shape in a drawable resource xml file in the res/drawable folder. Then apply the shape to a button view using its background attribute.
There are four valid shapes that you can define. They are rectangle, line, oval, and ring. The root element of the shape resource file must be

<shape>. You can specify attributes such as corners, gradient, padding, size, solid color, and stroke to your shape using <corners>, <gradient>, <padding>, <size>, <solid>, and <stroke> elements.  In the <corners> element, you can specify the radius of all corners or any corner of the shape. The <gradient> specifies a gradient color of the shape. With The <padding> element, you can set the left, right bottom, and top padding of the view that the shape is applied to. The <size> element specifies the width and height of the shape. The <solid> element fills a color to the shape. The <stroke> element helps you to specify a line stroke for the shape.

Now to have an example application on button shape, you create a new Android project. Then modify the activity_main.xml file to add two Buttons. The first button will have a round-rectangle shape with white color filled in and the second button has over shape with gradient color. All buttons have a red-line border.

 
 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.shapedrawable.MainActivity" >
 
    <Button
       android:id="@+id/bt1"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"      
       android:text="Button1"
       android:layout_marginBottom="20dp"
       android:background="@drawable/roundrect"
       
       />
      <Button
       android:id="@+id/bt2"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_below="@+id/bt1"
       android:text="Button2"
       android:background="@drawable/ovalgradient"
       />
    
   />
 
 </RelativeLayout>

 
 In the res/drawable folder, you create two drawable resource xml files. One file is roundrect.xml file that defines a round rectangle shape with the white sold color to the first button. Another file is called ovalgradient.xml. It defines the oval shape with gradient color for the second button.
 
 Roundrect.xml file
 
<?xml version="1.0" encoding="utf-8"?>
 
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners
       android:radius="10dp"
      />
     <gradient
       android:angle="90"
       android:centerColor="#783309"
       android:endColor="#78ea89"
       android:gradientRadius="2"
       android:startColor="#f98344"
       android:type="linear"
   		/>
     <padding
       android:left="15dp"
       android:top="5dp"
       android:right="15dp"
       android:bottom="5dp" />
     <size
       android:width="200dp"
       android:height="30dp" />
     <solid
       android:color="#FFFFFF" />
      <stroke
       android:width="2dp"
       android:color="#FF0000"
       android:dashWidth="1dp"
       android:dashGap="1dp" />
 </shape>

 
 Ovalgradient.xml file
 
<?xml version="1.0" encoding="utf-8"?>
 
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
     <gradient
       android:angle="90"
       android:centerColor="#783309"
       android:endColor="#78ea89"
       android:gradientRadius="2"
       android:startColor="#f98344"
       android:type="linear"
   		/>
     <padding
       android:left="15dp"
       android:top="15dp"
       android:right="15dp"
       android:bottom="15dp" />
     <stroke
       android:width="5dp"
       android:color="#FF0000"
       android:dashWidth="0dp"
       android:dashGap="0dp" />
 </shape>

 
 When you run this example application you get the output as shown in the picture below.
 

Android-button-shape

 

 


  • 0

Zoom Image Demo In Android

Category : Uncategorized

Zoom Image Demo In Android | Zoom Image Example with code in Android | Motion Event, Matrix example in Android

Hello friends!
Today I am going to share zoom image code in Android using TouchListner, MotionEvent, Matrix.
Please copy paste below code and enjoy!

1-Print Screen

   
2-MainActivity

package com.manish.zoomimage;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.os.Bundle;
import android.util.FloatMath;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;

public class MainActivity extends Activity {
 ImageView imageDetail;
 Matrix matrix = new Matrix();
 Matrix savedMatrix = new Matrix();
 PointF startPoint = new PointF();
 PointF midPoint = new PointF();
 float oldDist = 1f;
 static final int NONE = 0;
 static final int DRAG = 1;
 static final int ZOOM = 2;
 int mode = NONE;

 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  imageDetail = (ImageView) findViewById(R.id.imageView1);
  /**
   * set on touch listner on image
   */
  imageDetail.setOnTouchListener(new View.OnTouchListener() {

   @Override
   public boolean onTouch(View v, MotionEvent event) {

    ImageView view = (ImageView) v;
    System.out.println("matrix=" + savedMatrix.toString());
    switch (event.getAction() & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN:

     savedMatrix.set(matrix);
     startPoint.set(event.getX(), event.getY());
     mode = DRAG;
     break;

    case MotionEvent.ACTION_POINTER_DOWN:

     oldDist = spacing(event);

     if (oldDist > 10f) {
      savedMatrix.set(matrix);
      midPoint(midPoint, event);
      mode = ZOOM;
     }
     break;

    case MotionEvent.ACTION_UP:

    case MotionEvent.ACTION_POINTER_UP:
     mode = NONE;

     break;

    case MotionEvent.ACTION_MOVE:
     if (mode == DRAG) {
      matrix.set(savedMatrix);
      matrix.postTranslate(event.getX() - startPoint.x,
        event.getY() - startPoint.y);
     } else if (mode == ZOOM) {
      float newDist = spacing(event);
      if (newDist > 10f) {
       matrix.set(savedMatrix);
       float scale = newDist / oldDist;
       matrix.postScale(scale, scale, midPoint.x, midPoint.y);
      }
     }
     break;

    }
    view.setImageMatrix(matrix);

    return true;
   }

   @SuppressLint("FloatMath")
   private float spacing(MotionEvent event) {
    float x = event.getX(0) - event.getX(1);
    float y = event.getY(0) - event.getY(1);
    return FloatMath.sqrt(x * x + y * y);
   }

   private void midPoint(PointF point, MotionEvent event) {
    float x = event.getX(0) + event.getX(1);
    float y = event.getY(0) + event.getY(1);
    point.set(x / 2, y / 2);
   }
  });

 }

}

3-activity_main

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="matrix"
        android:src="@drawable/images" />

</RelativeLayout>

Thanks!


  • 0

Android Custom Shape Image view

Category : Uncategorized

Android Custom Shape Imageview| Rounded Image View in Android | Circuler ImageView in Android | Oval Image View in Android | Triangle Imageview in Android | Hexagonal Shape Imageview in Android

Hello Friend,

Today I am sharing an article for custom shape image-view in android using canvas. There is no library needed, using canvas you can make any type of shape with simple java code. You can make any shape like- circle, oval, triangle, Hexagonal or any thing else. Below is the code copy to them according to your need.

1)MainActivity.java-
package com.androidhub4you.crop;

import android.app.Activity;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.os.Bundle;

import android.widget.ImageView;

public class MainActivity extends Activity {

 

private ImageView imageViewRound;

private ImageView imageViewOval;

private ImageView imageViewTriangle;

private ImageView imageViewHexaGon;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

imageViewRound=(ImageView)findViewById(R.id.imageView_round);

imageViewOval=(ImageView)findViewById(R.id.imageView_oval);

imageViewTriangle=(ImageView)findViewById(R.id.imageView_triangle);

imageViewHexaGon=(ImageView)findViewById(R.id.imageView_hexagon);

 

Bitmap icon = BitmapFactory.decodeResource(getResources(),R.drawable.pic1);

 

imageViewRound.setImageBitmap(icon);

imageViewOval.setImageBitmap(icon);

imageViewTriangle.setImageBitmap(icon);

imageViewHexaGon.setImageBitmap(icon);

 

 

}

 

}

2)activity_main.xml-

<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”

xmlns:tools=“http://schemas.android.com/tools”

android:layout_width=“match_parent”

android:layout_height=“match_parent”

android:gravity=“center”

android:orientation=“vertical”

tools:context=“.MainActivity” >

<com.androidhub4you.crop.RoundedImageView

android:id=“@+id/imageView_round”

android:layout_width=“100dp”

android:layout_height=“100dp”

android:layout_marginTop=“15dp”

android:src=“@drawable/ic_launcher” />

<com.androidhub4you.crop.OvalImageView

android:id=“@+id/imageView_oval”

android:layout_width=“100dp”

android:layout_height=“100dp”

android:layout_marginTop=“15dp”

android:src=“@drawable/ic_launcher” />

<com.androidhub4you.crop.TriangleImageView

android:id=“@+id/imageView_triangle”

android:layout_width=“100dp”

android:layout_height=“100dp”

android:layout_marginTop=“15dp”

android:src=“@drawable/ic_launcher” />

<com.androidhub4you.crop.HexagonImageView

android:id=“@+id/imageView_hexagon”

android:layout_width=“100dp”

android:layout_height=“100dp”

android:layout_marginTop=“15dp”

android:src=“@drawable/ic_launcher” />

</LinearLayout>

Circle Shape:

package com.androidhub4you.crop;

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.Mode;

import android.graphics.PorterDuffXfermode;

import android.graphics.Rect;

import android.graphics.drawable.BitmapDrawable;

import android.graphics.drawable.Drawable;

import android.util.AttributeSet;

import android.widget.ImageView;

public class RoundedImageView extends ImageView {

public RoundedImageView(Context ctx, AttributeSet attrs) {

super(ctx, attrs);

}

@Override

protected void onDraw(Canvas canvas) {

Drawable drawable = getDrawable();

if (drawable == null) {

return;

}

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

return;

}

Bitmap b = ((BitmapDrawable) drawable).getBitmap();

Bitmap bitmap = b.copy(Bitmap.Config.ARGB_8888, true);

int w = getWidth(), h = getHeight();

Bitmap roundBitmap = getRoundedCroppedBitmap(bitmap, w);

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

}

public static Bitmap getRoundedCroppedBitmap(Bitmap bitmap, int radius) {

Bitmap finalBitmap;

if (bitmap.getWidth() != radius || bitmap.getHeight() != radius)

finalBitmap = Bitmap.createScaledBitmap(bitmap, radius, radius,

false);

else

finalBitmap = bitmap;

Bitmap output = Bitmap.createBitmap(finalBitmap.getWidth(),

finalBitmap.getHeight(), Config.ARGB_8888);

Canvas canvas = new Canvas(output);

final Paint paint = new Paint();

final Rect rect = new Rect(0, 0, finalBitmap.getWidth(),

finalBitmap.getHeight());

paint.setAntiAlias(true);

paint.setFilterBitmap(true);

paint.setDither(true);

canvas.drawARGB(0, 0, 0, 0);

paint.setColor(Color.parseColor(“#BAB399”));

canvas.drawCircle(finalBitmap.getWidth() / 2 + 0.7f,

finalBitmap.getHeight() / 2 + 0.7f,

finalBitmap.getWidth() / 2 + 0.1f, paint);

paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));

canvas.drawBitmap(finalBitmap, rect, rect, paint);

return output;

}

}

Oval Shape:

package com.androidhub4you.crop;

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.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 OvalImageView extends ImageView {

public OvalImageView(Context ctx, AttributeSet attrs) {

super(ctx, attrs);

}

@Override

protected void onDraw(Canvas canvas) {

Drawable drawable = getDrawable();

if (drawable == null) {

return;

}

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

return;

}

Bitmap b = ((BitmapDrawable) drawable).getBitmap();

Bitmap bitmap = b.copy(Bitmap.Config.ARGB_8888, true);

int w = getWidth(), h = getHeight();

Bitmap roundBitmap = getOvalCroppedBitmap(bitmap, w);

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

}

public static Bitmap getOvalCroppedBitmap(Bitmap bitmap, int radius) {

Bitmap finalBitmap;

if (bitmap.getWidth() != radius || bitmap.getHeight() != radius)

finalBitmap = Bitmap.createScaledBitmap(bitmap, radius, radius,

false);

else

finalBitmap = bitmap;

Bitmap output = Bitmap.createBitmap(finalBitmap.getWidth(),

finalBitmap.getHeight(), Config.ARGB_8888);

Canvas canvas = new Canvas(output);

Paint paint = new Paint();

final Rect rect = new Rect(0, 0, finalBitmap.getWidth(),

finalBitmap.getHeight());

paint.setAntiAlias(true);

paint.setFilterBitmap(true);

paint.setDither(true);

canvas.drawARGB(0, 0, 0, 0);

paint.setColor(Color.parseColor(“#BAB399”));

RectF oval = new RectF(0, 0, 130, 150);

canvas.drawOval(oval, paint);

paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));

canvas.drawBitmap(finalBitmap, rect, oval, paint);

return output;

}

}

Triangle Shape:

package com.androidhub4you.crop;

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.Path;

import android.graphics.Point;

import android.graphics.PorterDuff.Mode;

import android.graphics.PorterDuffXfermode;

import android.graphics.Rect;

import android.graphics.drawable.BitmapDrawable;

import android.graphics.drawable.Drawable;

import android.util.AttributeSet;

import android.widget.ImageView;

public class TriangleImageView extends ImageView {

public TriangleImageView(Context ctx, AttributeSet attrs) {

super(ctx, attrs);

}

@Override

protected void onDraw(Canvas canvas) {

Drawable drawable = getDrawable();

if (drawable == null) {

return;

}

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

return;

}

Bitmap b = ((BitmapDrawable) drawable).getBitmap();

Bitmap bitmap = b.copy(Bitmap.Config.ARGB_8888, true);

int w = getWidth(), h = getHeight();

Bitmap roundBitmap = getRoundedCroppedBitmap(bitmap, w);

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

}

public static Bitmap getRoundedCroppedBitmap(Bitmap bitmap, int radius) {

Bitmap finalBitmap;

if (bitmap.getWidth() != radius || bitmap.getHeight() != radius)

finalBitmap = Bitmap.createScaledBitmap(bitmap, radius, radius,

false);

else

finalBitmap = bitmap;

Bitmap output = Bitmap.createBitmap(finalBitmap.getWidth(),

finalBitmap.getHeight(), Config.ARGB_8888);

Canvas canvas = new Canvas(output);

Paint paint = new Paint();

final Rect rect = new Rect(0, 0, finalBitmap.getWidth(),

finalBitmap.getHeight());

Point point1_draw = new Point(75, 0);

Point point2_draw = new Point(0, 180);

Point point3_draw = new Point(180, 180);

Path path = new Path();

path.moveTo(point1_draw.x, point1_draw.y);

path.lineTo(point2_draw.x, point2_draw.y);

path.lineTo(point3_draw.x, point3_draw.y);

path.lineTo(point1_draw.x, point1_draw.y);

path.close();

canvas.drawARGB(0, 0, 0, 0);

paint.setColor(Color.parseColor(“#BAB399”));

canvas.drawPath(path, paint);

paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));

canvas.drawBitmap(finalBitmap, rect, rect, paint);

return output;

}

}

Hexagonal Shape:

package com.androidhub4you.crop;

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.Path;

import android.graphics.Point;

import android.graphics.PorterDuff.Mode;

import android.graphics.PorterDuffXfermode;

import android.graphics.Rect;

import android.graphics.drawable.BitmapDrawable;

import android.graphics.drawable.Drawable;

import android.util.AttributeSet;

import android.widget.ImageView;

public class HexagonImageView extends ImageView {

public HexagonImageView(Context ctx, AttributeSet attrs) {

super(ctx, attrs);

}

@Override

protected void onDraw(Canvas canvas) {

Drawable drawable = getDrawable();

if (drawable == null) {

return;

}

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

return;

}

Bitmap b = ((BitmapDrawable) drawable).getBitmap();

Bitmap bitmap = b.copy(Bitmap.Config.ARGB_8888, true);

int w = getWidth(), h = getHeight();

Bitmap roundBitmap = getRoundedCroppedBitmap(bitmap, w);

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

}

public static Bitmap getRoundedCroppedBitmap(Bitmap bitmap, int radius) {

Bitmap finalBitmap;

if (bitmap.getWidth() != radius || bitmap.getHeight() != radius)

finalBitmap = Bitmap.createScaledBitmap(bitmap, radius, radius,

false);

else

finalBitmap = bitmap;

Bitmap output = Bitmap.createBitmap(finalBitmap.getWidth(),

finalBitmap.getHeight(), Config.ARGB_8888);

Canvas canvas = new Canvas(output);

Paint paint = new Paint();

final Rect rect = new Rect(0, 0, finalBitmap.getWidth(),

finalBitmap.getHeight());

Point point1_draw = new Point(75, 0);

Point point2_draw = new Point(0, 50);

Point point3_draw = new Point(0, 100);

Point point4_draw = new Point(75, 150);

Point point5_draw = new Point(150, 100);

Point point6_draw = new Point(150, 50);

Path path = new Path();

path.moveTo(point1_draw.x, point1_draw.y);

path.lineTo(point2_draw.x, point2_draw.y);

path.lineTo(point3_draw.x, point3_draw.y);

path.lineTo(point4_draw.x, point4_draw.y);

path.lineTo(point5_draw.x, point5_draw.y);

path.lineTo(point6_draw.x, point6_draw.y);

path.close();

canvas.drawARGB(0, 0, 0, 0);

paint.setColor(Color.parseColor(“#BAB399”));

canvas.drawPath(path, paint);

paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));

canvas.drawBitmap(finalBitmap, rect, rect, paint);

return output;

}

}
Read more: http://www.androidhub4you.com/2014/10/android-custom-shape-imageview-rounded.html#ixzz454WS1eaK


  • 1

Rounded button with shadow in Android

Category : Uncategorized

To create a rounded button, we need to create a new shape resource and configure it as shown below. This shape resource has to be assigned to the button as background, and can not only be applied to a button, but also to any component, like text fields, list elements, etc.

Rounded corners

Create the resource file in /res/drawable with “shape” as root element and include the element “corners”. This element has the attribute “radius” to set the value of the radius for all corners. To set different values for different corners, use the attributes “bottomRightRadius”, “bottomLeftRadius”, “topRightRadius” and “topLeftRadius”.

A: rounded button
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<shape android:shape="rectangle"
   <gradient
     android:startColor="@color/drk_button"
     android:endColor="@color/lgt_button"
     android:angle="90">
   </gradient>
   <corners android:radius="20dip" />
  
   <stroke
     android:width="1px"
     android:color="@color/drk_button" />
</shape>

The gradient element is a gradient background and the stroke element configures the border of the button.

Shadow

The next step is to create the shadow. The effect of the shadow can be done by adding a second shape under the original button shape, changing its color to a darker one.

1
2
3
4
5
6
7
<shape android:shape="rectangle"
     <solid android:color="@color/black_alpha"/>
     <corners android:radius="20dip"/>
</shape>

To overlap different items we have to use a “layer-list” resource and include the previous shapes. The shadow should appear in first place and then the original button with some displacement. In this example, we are creating the shadow at the bottom of the button and an offset of 4px.

B: button with shadow
1
2
3
4
5
6
7
8
9
<layer-list
   <item android:drawable="@drawable/shadow"/>
   <item
     android:drawable="@drawable/button"
     android:bottom="4px" /> 
</layer-list>

Compare results

Compare buttons


  • 0

Creating a simple calculator

Category : Uncategorized

In the this lesson we will:

– write a calculator application

 

We will try to develop the simplest calculator, which takes two numbers and applies addition, subtraction, multiplication and division operations to them. The result is displayed as a complete expression.

Let’s create an project:

Project name: P0191_SimpleCalculator
Build Target: Android 2.3.3
Application name: SimpleCalculator
Package name: ru.startandroid.develop.simplecalculator
Create Activity: MainActivity

Open main.xml and draw the screen:

<?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”>
<LinearLayout
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:id=“@+id/linearLayout1”
android:layout_marginLeft=“10pt”
android:layout_marginRight=“10pt”
android:layout_marginTop=“3pt”>
<EditText
android:layout_weight=“1”
android:layout_height=“wrap_content”
android:layout_marginRight=“5pt”
android:id=“@+id/etNum1”
android:layout_width=“match_parent”
android:inputType=“numberDecimal”>
</EditText>
<EditText
android:layout_height=“wrap_content”
android:layout_weight=“1”
android:layout_marginLeft=“5pt”
android:id=“@+id/etNum2”
android:layout_width=“match_parent”
android:inputType=“numberDecimal”>
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width=“match_parent”
android:layout_height=“wrap_content”
android:id=“@+id/linearLayout2”
android:layout_marginTop=“3pt”
android:layout_marginLeft=“5pt”
android:layout_marginRight=“5pt”>
<Button
android:layout_height=“wrap_content”
android:layout_width=“match_parent”
android:layout_weight=“1”
android:text=“+”
android:textSize=“8pt”
android:id=“@+id/btnAdd”>
</Button>
<Button
android:layout_height=“wrap_content”
android:layout_width=“match_parent”
android:layout_weight=“1”
android:text=“-“
android:textSize=“8pt”
android:id=“@+id/btnSub”>
</Button>
<Button
android:layout_height=“wrap_content”
android:layout_width=“match_parent”
android:layout_weight=“1”
android:text=“*”
android:textSize=“8pt”
android:id=“@+id/btnMult”>
</Button>
<Button
android:layout_height=“wrap_content”
android:layout_width=“match_parent”
android:layout_weight=“1”
android:text=“/”
android:textSize=“8pt”
android:id=“@+id/btnDiv”>
</Button>
</LinearLayout>
<TextView
android:layout_height=“wrap_content”
android:layout_width=“match_parent”
android:layout_marginLeft=“5pt”
android:layout_marginRight=“5pt”
android:textSize=“12pt”
android:layout_marginTop=“3pt”
android:id=“@+id/tvResult”
android:gravity=“center_horizontal”>
</TextView>
</LinearLayout>

We have two input fields here, four buttons and a text field for output. Have a look at inputType attribute for EditText. It defines the type of the content. I’ve specified numberDecimal – that is field can only contain numbers and a dot, it will not allow letters. It is convenient as you don’t have to code any checkings.

For the TextView gravity attribute is specified. It defines how will the text in the TextView will be located. Don’t confuse it with layout_gravity which is responsible for TextView location in a ViewGroup.

Now we need to read field contents, define which buttons has been pressed and output the needed result. Open MainActivity.java and write the code:

public class MainActivity extends Activity implements OnClickListener {

EditText etNum1;
EditText etNum2;

Button btnAdd;
Button btnSub;
Button btnMult;
Button btnDiv;

TextView tvResult;

String oper = "";

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView
(R.layout.main);

// find the elements
etNum1 = (EditText) findViewById(R.id.etNum1);
etNum2 =
(EditText) findViewById(R.id.etNum2);

btnAdd = (Button) findViewById(R.id.btnAdd);
btnSub =
(Button) findViewById(R.id.btnSub);
btnMult =
(Button) findViewById(R.id.btnMult);
btnDiv =
(Button) findViewById(R.id.btnDiv);

tvResult = (TextView) findViewById(R.id.tvResult);

// set a listener
btnAdd.setOnClickListener(this);
btnSub.setOnClickListener
(this);
btnMult.setOnClickListener
(this);
btnDiv.setOnClickListener
(this);

}

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
float num1 = 0;
float num2 = 0;
float result = 0;

// check if the fields are empty
if (TextUtils.isEmpty(etNum1.getText().toString())
|| TextUtils.isEmpty(etNum2.getText().toString())) {
return;
}

// read EditText and fill variables with numbers
num1 = Float.parseFloat(etNum1.getText().toString());
num2 = Float.parseFloat
(etNum2.getText().toString());

// defines the button that has been clicked and performs the corresponding operation
// write operation into oper, we will use it later for output
switch (v.getId()) {
case R.id.btnAdd:
oper =
"+";
result = num1 + num2;
break;
case R.id.btnSub:
oper =
"-";
result = num1 - num2;
break;
case R.id.btnMult:
oper =
"*";
result = num1 * num2;
break;
case R.id.btnDiv:
oper =
"/";
result = num1 / num2;
break;
default:
break;
}

// form the output line
tvResult.setText(num1 + " " + oper + " " + num2 + " = " + result);
}
}

I guess everything is clear in comments. Read values, define the button, perform an operation and output to the text field. Activity is a listener of the clicked buttons.

Save everything and run.

Let’s extend the functionality by making menu with clearing fields and exit items. Items will be named Reset and Quit.

Add two constants – these will be IDs of the menu items.

public class MainActivity extends Activity implements OnClickListener {

final int MENU_RESET_ID = 1;
final int MENU_QUIT_ID = 2
;

EditText etNum1;

(add only the underlined code)

And write code for menu creation and processing:

  // menu creation
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
menu.add(0, MENU_RESET_ID, 0, "Reset");
menu.add
(0, MENU_QUIT_ID, 0, "Quit");
return super.onCreateOptionsMenu(menu);
}

// process menu item clicks
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case MENU_RESET_ID:
// clear the fields
etNum1.setText("");
etNum2.setText
("");
tvResult.setText
("");
break;
case MENU_QUIT_ID:
// exit the application
finish();
break;
}
return super.onOptionsItemSelected(item);
}

Save everything and run. Two menu items appeared:

Reset – clears all the fields
Quit – closes the application


  • 0

How-to: Customize Android progress bars

Category : Uncategorized

Introduction to Android progress bars

This how-to will show you how to customize Android’s default progress bar to fully suit your needs. You will create an application that demonstrates different styles of progress bar. The end result will be something like this:

End result of learning how to style Android progress bars

If you want to take a look at the result on your own phone, you can just download the apk file. Or get the source.

After this how-to, you will know

  • How to fully customize Android’s horizontal progress bar
  • How to fully customize an indeterminate progress bar
  • What the default progress bar looks like on different API levels
  • How to use drawables to style widgets
The stock progress bar on different API levels

The stock progress bar on different API levels

The default progress bar

By default, the looks of the progress bar are determined by the system. This look has changed quite a bit through different Android versions.

The are good reasons to want your own, custom style for a progress bar. For instance, maybe your application features a color theme and you want the progress bar to fit in. Or maybe you want the progress bar to show a gradient. Whatever the reason, this tutorial will show you how to do it.

Customizing progress bars on Android

To start, download the project for this how-to. The starting project contains one Activity with no relevant code and one layout. The layout contains four progress bars, all in the default style. During this how-to we will change the style of three of the progress bars. When you’ve opened the project in your favorite IDE you should be able to view the layout and see something like this:

Tutorial starting point screenshot

Changing the progress bar drawable

Just like all the other widgets you use when creating an Android application, the progress bar allows changing some of its settings through the layout xml-file. For instance, by setting

1
android:progress="50"

the progress bar will show 50% progress. Note that this is the value that’s used in the tutorial project. You can experiment by changing this value anywhere between 0 and 100, you should see the progress indicator change accordingly in your visual editor.

By default, your progress bar will use the system drawable. For instance, on API level 17 this will be

1
@android:drawable/progress_horizontal_holo_light

This can be changed by adding a tag in the layout xml file. In order to change the drawable (and thus the style) for the second progress bar in this how-to, change the xml for that progress bar to:

01
02
03
04
05
06
07
08
09
10
<ProgressBar
    android:id="@+id/progressBar2"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/progressBar1"
    android:layout_marginTop="30dp"
    android:progress="50"
    android:progressDrawable="@drawable/progressbar2" />

You will probably get an error on this, which should be telling you your IDE is doing its job as we didn’t create the progressbar2 drawable yet. Let’s do that now to resolve this error. Add a new text file named progressbar2.xml to the /res/drawable directory. The contents of this xml file should be

1
2
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
</layer-list>

Note that there is no qualifier such as mdpi or xhdpi appended to the name of the drawable directory. This ensures that the drawable for the progressbar we’re about to create will be the same on all devices. Of course, if you don’t want that you could create different progress bar styles for different devices, but we won’t do so in this tutorial.

The element will be the root element of this drawable. It allows us to define an array of other drawables that will be drawn in the order they are defined. With this, the error your IDE throwed on the missing drawable should be gone. However, you’ll notice that the second scrollbar itself is gone as well. This too makes sense. After all, we’ve overruled the default drawable with an empty one, so nothing will be drawn!

A simple custom progress bar

To fix this we’ll have to define how the progress bar should be drawn. For this first one, we’ll make a progress bar with rounded corners. Its background will be a vertical gradient of two shades of gray (graydient!?), and when there’s progress it will show this by filling up with a gradient of blue to green from left to right. For this, put the following in the progressbar2.xml file:

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
  <item android:id="@android:id/background">
    <shape>
      <corners android:radius="5dip" />
      <gradient
        android:angle="270"
        android:centerColor="#ff5a5d5a"
        android:centerY="0.5"
        android:endColor="#ff747674"
        android:startColor="#ff9d9e9d" />
    </shape>
  </item>
  <item android:id="@android:id/progress">
    <clip>
      <shape>
        <corners android:radius="5dip" />
          <gradient
            android:angle="0"
            android:endColor="#ff009900"
            android:startColor="#ff000099" />
      </shape>
    </clip>
  </item>
</layer-list>

This should result in a progress bar like this (shown here with 25%, 50%, and 75% progress):

A simple custom styled progress bar

Now, let’s go through the xml to learn how we got this effect. Notice that the xml contains two tags. The first one defines the background, the second defines how the progress bar will fill depending on the actual progress. The background is defined as a <shape>. This shape is said to have corners with a radius of 5dp, which causes the slightly rounded corners the progress bar has. Apart from this, the shape is defined by a <gradient> tag. The colors defined in the gradient are pretty self-descriptive. The angle is in degrees and defines the direction of the gradient. An angle of 270 degrees means that the start of the gradient will be at the bottom and the end will be at the top. Note that the angle has to be a multiple of 45, otherwise you’ll get this error: org.xmlpull.v1.XmlPullParserException: <internal -- stub if needed><gradient> tag requires 'angle' attribute to be a multiple of 45

The second tag also contains a shape with rounded corners and a gradient. This gradient is from left to right (the angle is 0), and it is from blue to green. Main difference with the background drawable is that this one is wrapped in a tag. The clip drawable  is not unique to progress bars, but in general can be used to reveal another drawable based on a level (in case of progress bars, the progress directly defines the clip drawable level). For a progress bar in this style to work the clip drawable is mandatory. Removing it will cause the progress bar to always show 100% progress.

An indeterminate progress bar

As a programmer, you can’t always tell how much progress is being made. Sometimes you just want an indicator to show that your program is actually working, but you don’t know if it’s 10%, 50%, or 99% done. This is called an indeterminate progress bar. Often, a spinning wheel animation is used for the indeterminate progress bar. However, there’s also a horizontal version of the indeterminate progress bar, which looks like this (but animated obviously):

Default indeterminate progress bar

To customize the indeterminate progress bar, add this tag to the layout xml file:

1
android:indeterminateDrawable="@drawable/progressbar3" android:minHeight="48dp"

Similar to how we changed the layout for the second progress bar by setting the drawable, we’ll change the layout for the indeterminate progress bar by setting the indeterminateDrawable value. Again, this will result in a warning in your IDE because there is no /res/drawable/progressbar3.xml. Let’s create that file, and fill it with:

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="360" >
    <shape
        android:shape="oval"
        android:useLevel="false" >
        <size
            android:height="48dip"
            android:width="48dip" />
        <gradient
            android:centerColor="#ff000000"
            android:centerY="0.50"
            android:endColor="#ff00ff00"
            android:startColor="#ff000000"
            android:type="sweep"
            android:useLevel="false" />
    </shape>
</rotate>

Using this as drawable for the indeterminate progress bar will result in a progress bar that looks somewhat like the classic radar screens we all know from the movies:

Radar-styled indeterminate progress bar

This progress bar is rotating, because its top-level drawable is a tag, indicating it should rotate from 0 to 360 degrees around the center of the drawable. Apart from that, it’s defined mostly by the tag. This tag indicates that the shape should be oval, which results in a round shape because the available space is square. It’s filled with a sweep-gradient, which causes the typical green-to-black colors. And that without a single line of code, pretty cool, right?

Going crazy with progress bar styling

Now that we’ve got some tools that help us create custom progress bars, we’re mainly limited by our imagination. What kind of crazy progress bar could you come up with? I’ll give one example to end this tutorial:

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:id="@android:id/background">
        <shape android:shape="rectangle" >
            <corners android:radius="15dip" />
            <stroke
                android:width="5dip"
                android:color="#ff0000ff" />
            <gradient
                android:centerColor="#ff000000"
                android:endColor="#ffff0000"
                android:gradientRadius="200"
                android:startColor="#ff00ff00"
                android:type="radial" />
        </shape>
    </item>
    <item android:id="@android:id/progress">
        <rotate
            android:fromDegrees="0"
            android:pivotX="50%"
            android:pivotY="50%"
            android:toDegrees="90" >
            <shape android:shape="rectangle" >
                <corners android:radius="15dip" />
                <solid
                    android:color="#aaf4e329"
                    />
                <stroke
                    android:width="5dip"
                    android:color="#ff0000ff" />
            </shape>
        </rotate>
    </item>
</layer-list>

This will give you a progress bar on drugs, like this (showing 0%, 25%, 50%, 75%, and 100% progress):

Progress bar styled crazy

I’ll leave it to you to figure out how we got this effect. Good luck with your own progress bars!


  • 0

Define shape of rounded-rect for View using XML

Category : Uncategorized

This example demonstrate how to define rounded-rect shape for View, in XML; to implement layout as shown here:

rounded-rect shape

Create /res/drawable/roundrect.xml to define our custom shape.

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners
        android:radius="15dp" />
    <gradient
        android:angle="90"
        android:startColor="#FF000000"
        android:endColor="#FFFFFFFF"
        android:type= "linear" />   
    <stroke
        android:width="1dp"
        android:color="#FF000000" />
    <padding
        android:left="15dp"
        android:top="15dp"
        android:right="15dp"
        android:bottom="15dp" />
</shape>

Include View using the custom shape, with android:background=”@drawable/roundrect”.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="10dp"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="@drawable/roundrect" >
        
        <ImageView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"
            android:background="@drawable/roundrect" />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="normal TextView"
            android:layout_margin="5dp" />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="TextView with roundrect"
            android:layout_margin="5dp"
            android:background="@drawable/roundrect" />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="normal EditText"
            android:layout_margin="5dp" />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="EditText with roundrect"
            android:text="Hello"
            android:layout_margin="5dp"
            android:background="@drawable/roundrect" />
    </LinearLayout>

</LinearLayout>

  • 0

A Guide to Android Recycler View and CardView

Category : Uncategorized

The new support library in Android L introduced two new UI widgets: RecyclerView and CardView. The RecyclerView is a more advanced and more flexible version of the ListView. This new component is a big step because the ListView is one of the most used UI widgets. The CardView widget, on the other hand, is a new component that does not “upgrade” an existing component. In this tutorial, I’ll explain how to use these two widgets and show how we can mix them. Let’s start by diving into the RecyclerView.

RecyclerView: Introduction

As I mentioned, RecyclerView is more flexible that ListView even if it introduces some complexities. We all know how to use ListView in our app and we know if we want to increase the ListView performances we can use a pattern called ViewHolder. This pattern consists of a simple class that holds the references to the UI components for each row in the ListView. This pattern avoids looking up the UI components all the time the system shows a row in the list. Even if this pattern introduces some benefits, we can implement the ListView without using it at all. RecyclerView forces us to use the ViewHolder pattern. To show how we can use the RecyclerView, we can suppose we want to create a simple app that shows a list of contact cards. The first thing we should do is create the main layout. RecyclerView is very similar to the ListView and we can use them in the same way:

  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2.       xmlns:tools="http://schemas.android.com/tools"
  3.       android:layout_width="match_parent"
  4.       android:layout_height="match_parent"
  5.       android:paddingLeft="@dimen/activity_horizontal_margin"
  6.       android:paddingRight="@dimen/activity_horizontal_margin"
  7.       android:paddingTop="@dimen/activity_vertical_margin"
  8.       android:paddingBottom="@dimen/activity_vertical_margin"
  9.       tools:context=".MyActivity">
  10.       <android.support.v7.widget.RecyclerView
  11.              android:id="@+id/cardList"
  12.              android:layout_width="match_parent"
  13.              android:layout_height="match_parent"
  14.        />    
  15. </RelativeLayout>

As you’ll notice from the layout shown above, the RecyclerView is available in the Android support library, so we have to modify build.gradle to include this dependency:

  1. dependencies {
  2.        ...    
  3.        compile 'com.android.support:recyclerview-v7:21.0.0-rc1'
  4.  }

Now, in the onCreate method we can get the reference to our RecyclerView and configure it:

  1. @Override
  2. protected void onCreate(Bundle savedInstanceState) {
  3.       super.onCreate(savedInstanceState);
  4.       setContentView(R.layout.activity_my);
  5.       RecyclerView recList = (RecyclerView) findViewById(R.id.cardList);
  6.       recList.setHasFixedSize(true);
  7.       LinearLayoutManager llm = new LinearLayoutManager(this);
  8.       llm.setOrientation(LinearLayoutManager.VERTICAL);
  9.       recList.setLayoutManager(llm);
  10. }

If you look at the code above, you’ll notice some differences between the RecyclerView and ListView. RecyclerView requires a layout manager. This component positions item views inside the row and determines when it is time to recycle the views. The library provides a default layout manager called LinearLayoutManager.

CardView

The CardView UI component shows information inside cards. We can customise its corners, the elevation and so on. We want to use this component to show contact information. These cards will be the rows of RecyclerView and we will see later how to integrate these two components. By now, we can define our card layout:

  1. <android.support.v7.widget.CardView
  2.       xmlns:card_view="http://schemas.android.com/apk/res-auto"
  3.       xmlns:android="http://schemas.android.com/apk/res/android"
  4.       android:id="@+id/card_view"
  5.       android:layout_width="match_parent"
  6.       android:layout_height="match_parent"
  7.       card_view:cardCornerRadius="4dp"
  8.       android:layout_margin="5dp">
  9.  
  10.   <RelativeLayout
  11.       android:layout_width="match_parent"
  12.       android:layout_height="match_parent">
  13.  
  14.      <TextView
  15.          android:id="@+id/title"
  16.          android:layout_width="match_parent"
  17.          android:layout_height="20dp"
  18.          android:background="@color/bkg_card"
  19.          android:text="contact det"
  20.          android:gravity="center_vertical"
  21.          android:textColor="@android:color/white"
  22.          android:textSize="14dp"/>
  23.  
  24.     <TextView
  25.         android:id="@+id/txtName"
  26.         android:layout_width="wrap_content"
  27.         android:layout_height="wrap_content"
  28.         android:text="Name"
  29.         android:gravity="center_vertical"
  30.         android:textSize="10dp"
  31.         android:layout_below="@id/title"
  32.         android:layout_marginTop="10dp"
  33.         android:layout_marginLeft="5dp"/>
  34.  
  35.     <TextView
  36.         android:id="@+id/txtSurname"
  37.         android:layout_width="wrap_content"
  38.         android:layout_height="wrap_content"
  39.         android:text="Surname"
  40.         android:gravity="center_vertical"
  41.         android:textSize="10dp"
  42.         android:layout_below="@id/txtName"
  43.         android:layout_marginTop="10dp"
  44.         android:layout_marginLeft="5dp"/>
  45.  
  46.     <TextView
  47.         android:id="@+id/txtEmail"
  48.         android:layout_width="wrap_content"
  49.         android:layout_height="wrap_content"
  50.         android:text="Email"
  51.         android:textSize="10dp"
  52.         android:layout_marginTop="10dp"
  53.         android:layout_alignParentRight="true"
  54.         android:layout_marginRight="150dp"
  55.         android:layout_alignBaseline="@id/txtName"/>
  56.  
  57. </RelativeLayout>

As you can see, the CardView is very simple to use. This component is available in another android support library so we have to add this dependency too:

  1. dependencies {
  2.         compile 'com.android.support:cardview-v7:21.0.0-rc1'
  3.         compile 'com.android.support:recyclerview-v7:21.0.0-rc1'
  4.  }

RecyclerView: Adapter

The adapter is a component that stands between the data model we want to show in our app UI and the UI component that renders this information. In other words, an adapter guides the way the information are shown in the UI. So if we want to display our contacts, we need an adapter for the RecyclerView. This adapter must extend a class called RecyclerView.Adapter passing our class that implements the ViewHolder pattern:

public class MyAdapter extends RecyclerView.Adapter<MyHolder> { ..... }

We now have to override two methods so that we can implement our logic: onCreateViewHolder is called whenever a new instance of our ViewHolder class is created, and onBindViewHolder is called when the SO binds the view with the data — or, in other words, the data is shown in the UI.

In this case, the adapter helps us combine the RecyclerView and CardView. The layout we defined before for the cards will be the row layout of our contact list in the RecyclerView. Before doing it, we have to define our data model that stands at the base of our UI (i.e. what information we want to show). For this purpose, we can define a simple class:

  1. public class ContactInfo {
  2.       protected String name;
  3.       protected String surname;
  4.       protected String email;
  5.       protected static final String NAME_PREFIX = "Name_";
  6.       protected static final String SURNAME_PREFIX = "Surname_";
  7.       protected static final String EMAIL_PREFIX = "email_";
  8. }

And finally, we are ready to create our adapter. If you remember what we said before about Viewholder pattern, we have to code our class that implements it:

  1. public static class ContactViewHolder extends RecyclerView.ViewHolder {
  2.      protected TextView vName;
  3.      protected TextView vSurname;
  4.      protected TextView vEmail;
  5.      protected TextView vTitle;
  6.  
  7.      public ContactViewHolder(View v) {
  8.           super(v);
  9.           vName =  (TextView) v.findViewById(R.id.txtName);
  10.           vSurname = (TextView)  v.findViewById(R.id.txtSurname);
  11.           vEmail = (TextView)  v.findViewById(R.id.txtEmail);
  12.           vTitle = (TextView) v.findViewById(R.id.title);
  13.       }
  14.  }

Look at the code, in the class constructor we get the reference to the views we defined in our card layout. Now it is time to code our adapter:

  1. public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactViewHolder> {
  2.  
  3.     private List<ContactInfo> contactList;
  4.  
  5.     public ContactAdapter(List<ContactInfo> contactList) {
  6.             this.contactList = contactList;
  7.     }
  8.  
  9.     @Override
  10.     public int getItemCount() {
  11.           return contactList.size();
  12.     }
  13.  
  14.     @Override
  15.     public void onBindViewHolder(ContactViewHolder contactViewHolder, int i) {
  16.         ContactInfo ci = contactList.get(i);
  17.         contactViewHolder.vName.setText(ci.name);
  18.         contactViewHolder.vSurname.setText(ci.surname);
  19.         contactViewHolder.vEmail.setText(ci.email);
  20.         contactViewHolder.vTitle.setText(ci.name + " " + ci.surname);
  21.    }
  22.  
  23.    @Override
  24.    public ContactViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
  25.         View itemView = LayoutInflater.
  26.                     from(viewGroup.getContext()).
  27.                     inflate(R.layout.card_layout, viewGroup, false);
  28.  
  29.         return new ContactViewHolder(itemView);
  30.    }
  31.  
  32.   public static class ContactViewHolder extends RecyclerView.ViewHolder {
  33.       ...
  34.   }
  35. }

In our implementation, we override onBindViewHolder where we bind the data (our contact info) to the Views. Notice that we don’t look up UI components but simply use the references stored in our ContactViewHolder. In onCreateViewHolder we return our ContactViewHolder inflating the row layout (the CardView in our case).

Run the app and you’ll get the results shown below:

Android RecyclerView with Cardview

 


  • 0

Google Play Terms of Service

Category : Uncategorized

Google Play

Google Play Terms of Service

December 9, 2015

1. Introduction

Applicable Terms. Thanks for using Google Play. Google Play is a service provided by Google Inc. (“Google”, “we” or “us”), located at 1600 Amphitheatre Parkway, Mountain View California 94043, USA, and is subject to the Google Terms of Service (“Google ToS”). Google Play is a “Service” as defined in the Google ToS, and these Google Play Terms of Service are additional terms which apply to the use of Google Play. Your use of Google Play and the digital content available on it is subject to these Google Play Terms of Service and the Google ToS (which together we refer to as the “Terms”).

If there is any conflict between the Google Play Terms of Service and the Google ToS, the Google Play Terms of Service shall prevail.

Your use of the Google Play store requires that you agree to the following terms. Please read them carefully. If you do not understand the Terms, or do not accept any part of them, then you should not use the Google Play store. Some products and features may be not available in all countries. Please see the Google Play Help Center for more information.

2. Provision of Google Play

Direct, Agency and App Sales. When you buy “Content” (defined as data files, applications, written text, mobile device software, music, audio files or other sounds, photographs, videos or other images) on Google Play you will buy it either:

(a) directly from Google (a “Direct Sale”);

(b) from the provider of the Content (the “Provider”), where Google is acting as an agent for the Provider (an “Agency Sale”); or

(c) in the case of Android apps, from the Provider of the app (an “App Sale”).

Each time that you purchase Content, you enter into a separate sale contract:

(d) based on the Terms (as applicable) with Google (in the case of a Direct Sale);

(e) based on the Terms (as applicable) with the Provider of the Content you have purchased (in the case of Agency Sales); or

(f) with the Provider of the Content you have purchased (in the case of App Sales).

The separate sale contract in (e) or (f) above (as applicable) is in addition to your contract with Google Inc. for the use of the Service (i.e. these Google Play Terms of Service).

For Agency Sales the statement, in the Google ToS, that the Google ToS “do not create any third party beneficiary rights”, does not apply to your use of the Service.

Access to Content. You may use Google Play to browse, locate, and/or download Content) for your mobile, computer or other supported device (“Device”). The availability of Content will vary between countries and not all Content may be available in your country. Some of this Content may be offered by Google while others may be made available by third-parties not affiliated with Google. Google is not responsible for any Content on Google Play that originates from a source other than Google and does not endorse such content.

3. Your Use of Google Play

Age Restrictions. In order to use Google Play you must be 13 years of age or older. If you are 13 or older but under 18 years of age, you must have your parent or legal guardian’s permission to use Google Play and to accept the Terms. In order to serve as the family manager of a family group on Google Play, you must be at least 18 years old. You must not access Google Play if you are a person who is either barred or otherwise legally prohibited from receiving or using the Service or any Content under the laws of the country in which you are resident or from which you access or use Google Play. You must comply with any additional age restrictions that might apply for the use of specific Content on Google Play.

Basic Use Requirements. To use the Service, you will need a Device that meets the system and compatibility requirements for the relevant Content, which may change from time to time, working Internet access, and compatible software. Your ability to use the Service and the performance of the Service may be affected by these factors. Such system requirements are your responsibility.

Third-Party Fees. You may incur access or data fees from third parties (such as your Internet provider or mobile carrier) in connection with your use of Content and Google Play. For instance, you may incur such fees if you use services provided through Google Play on or through third-party services or devices. You are responsible for all such fees.

Updates. You may need to install updates to Google Play or related Google software that we introduce from time to time to use Google Play and to access or download Content. Content originating from Google may communicate with Google servers from time to time to check for available updates to the Content and to the functionality of Google Play, such as bug fixes, patches, enhanced functions, missing plug-ins and new versions (collectively, “Updates”). Your use of the Content you have installed requires that you have agreed to receive such automatically requested Updates. If you do not agree to such automatically requested and received Updates then please do not use the Google Play store or install this Content.

Google may update any Google app or any app you have downloaded from Google Play to a new version of such app, irrespective of any update settings that you may have selected within the Google Play app or your Device, if Google determines that the update will fix a critical security vulnerability related to the app.

Information about You. In order to access certain services or Content on Google Play, you may be required to provide information about yourself such as your name, address, and billing details. The information we collect, including information obtained from third parties, is shared between Google and its group companies to operate the Service. Google’s privacy policies explain how we treat your personal data and protect your privacy when using Google Play. Any such information you provide to Google must always be accurate, correct and up to date. Google may need to provide your personal information, such as your name and email address, to Providers for the purposes of processing your transactions and/or provisioning Content to you. Google has agreed with Providers that they will use this information in accordance with their privacy policies.

If you are part of a family group on Google Play, your family members in the family group will be able to see certain information about you. If you are the family manager of a family group on Google Play, family members you invite to join the family group will see your name, photo, and e-mail address. If you join a family group as a family member, other family members will be able to see your name, photo, and e-mail address, and if you purchase Content using a family payment method, your family manager will see a record of every purchase you make, including a description of the Content.

Unauthorised Access to Accounts. You must keep your user details secure and must not share them with anyone else. You must not collect or harvest any personal data of any user of Google Play or of any user of other Google Services via Google Play, including account names.

Disabled Accounts. If Google disables access to your account in accordance with the Terms (for example if you violate the Terms), you may be prevented from accessing Google Play, your account details or any files or other Content that is stored with your account. If you are the family manager of a family on Google Play and Google disables access to your account, your family members may lose access to family features requiring a family group, such as a family payment method or family subscriptions. Please see section 6 below for your rights where you are not able to download Content before your account is disabled.

Malware protection. To protect you against malicious third party software and other security issues, Google may receive information about your device’s network connections, the operating system, and third party apps. Google may warn you if it considers an app to be unsafe, or remove or block its installation on your Device if it is known to be harmful to devices, data or users. You can choose to disable these protections in the Google Settings on your Device (however, apps installed through the Store may continue to be analyzed for security issues).

4. Purchases and Payments

Free Content. Google may allow you to download or use Content free of charge. Any terms and conditions that apply to purchased Content will apply to free Content, except with respect to payment-related matters (for example, the refund-related provisions of these terms do not apply to such free Content). Google may impose limitations on your access and use of certain free Content.

Purchase of Content. Your contract for the purchase and use of Content is completed once you receive the email from Google confirming your purchase of that Content, and performance of this contract begins as soon as the purchase is complete. If you are the family manager of a family group on Google Play, you will be required to set up a valid family payment method for your family members to use to purchase Content on Google Play and within apps. You will be responsible for all of your family members’ purchases of Content using the family payment method. If a family group is deleted, or a family member leaves the family group, you may be charged for pending purchases made by family members using the family payment method.

Google Payments. In order to purchase Content on Google Play, you must agree to the payment terms as specified in the Google Payments Terms of Service. If you do not have a Google Payment account, you can set one up by going to this link, where you can also find more information about Google Payments. The Payments Terms of Service and Privacy Notice also apply whenever you want to purchase Content using a Google Payments account. Please ensure that you read those terms carefully before making any purchase. Some purchases in Google Play will require you to transact with the product Provider directly. In these cases, to process your transaction and maintain your account, we may share your personal information with the product Provider, as permitted under the Payments Privacy Notice.

Other Payment Processing Methods. Google may make available to you various payment processing methods in addition to Google Payments account to facilitate the purchase of Content on Google Play. You must abide by any relevant terms and conditions or other legal agreement, whether with Google or a third party, that governs your use of a given payment processing method. Google may add or remove payment processing methods at its sole discretion and without notice to you. Once your purchase is complete, Google or Google’s payment processor may charge your credit card or other form of payment that you indicate for any Content ordered, along with any additional applicable amounts (including any taxes). You are solely responsible for all amounts payable associated with purchases you make on Google Play.

Eligibility for Carrier Billing. In order to determine your eligibility to have purchases of Content that you make through your mobile Devices billed to your mobile network provider’s account, when you create a Google Play account on a Device we will send identifiers of your Device, subscriber ID and SIM card serial number to your network provider. To permit this you will need to accept the network provider’s terms of service. The network provider may send us your billing address information to help us create your Google Play account. We will hold and use this information in accordance with Google’s Privacy Policies.

Pricing. Pricing and availability of all Content displayed on Google Play are subject to change at any time before you click the button indicating that you want to purchase Content.

Taxes. You are responsible for any Taxes, and must pay for Content without any reduction for Taxes. If the seller of Content is obligated to collect or pay Taxes, the Taxes will be charged to you.“Taxes” means any duties, customs fees, or taxes (other than income tax) associated with the sale of Content, including any related penalties or interest.

Compliance with Tax Laws. You must comply with any and all applicable tax laws, including the reporting and payment of any taxes arising in connection with your use of Google Play or the purchase of Content through Google Play. The reporting and payment of any such applicable taxes are your responsibility.

All Sales Final. Except as expressly set out in the Terms or Google’s refund policies displayed in the Service, all sales are final, and no returns, replacements or refunds are permitted. If a replacement, return or refund is granted for any transaction, the transaction may be reversed, and you may no longer be able to access the Content that you acquired through that transaction. Your rights to withdraw, cancel or return purchases and get a refund are set out in the additional terms for the relevant Content type set out below and the refund policies displayed in the Service.

Pre-orders.

(a) When you place a pre-order for a Product, your contract for the purchase and use of that item is completed when the Product becomes available in your account and you will be charged for the purchase at that time. You can cancel your pre-order at any time up to the point at which the Product becomes available to you (if you want to cancel the pre-order you will be able to do so by visiting the “My Orders” page and following the instructions there).

(b) After the moment when the Product becomes available to you, you will not able to withdraw or cancel the pre-order and your cancellation and return rights are the same as for other Products that you purchase through Google Play. Please see the terms below for more information.

(c) We will need to cancel your pre-order if the Product is withdrawn from sale in the store before it is made available and we reserve the right to cancel your order in the event the price changes before your order is fulfilled.

5. Subscriptions

Trials of Magazines News Content and Music. Subscribing to a free trial for a magazine or new content on Google Play Newsstand or for music (including as part of your purchase of a subscription for a magazine or music) gives you access to the subscription benefits for that magazine for free for a specified trial period. At the end of such trial period, you will be charged the price of the first period of the subscription and will continue to be charged until you cancel your subscription. To avoid being charged, you must cancel before the end of the trial period. If you cancel during the trial period you will retain access to the magazine issues that you access during a free trial period, but you will not retain access to news content or Music Subscription Content (as defined below) that you access during a free trial period unless you become a paid subscriber. Access to free trials may be limited to a certain number of free trials for each user during a given period. To avoid any charges, you must cancel before the end of the trial period; for more information on cancelling subscriptions, see the section titled ”Cancellations” below in this section 5.

Trials of Apps. Subscribing to a trial for an Android app gives you access to the subscription benefits for that app for free for a duration specified by the application developer. At the end of the trial period, you will be charged the price of the first period of the subscription and will continue to be charged until you cancel your subscription. To avoid being charged, you must cancel before the end of the trial period. Once you cancel your trial, you will immediately lose access to the relevant app and any subscription privileges.

Cancellations. If you purchase an auto-recurring periodic subscription (whether monthly, annual or another period) to Content, you may cancel that subscription at any time before the end of the applicable billing cycle, and the cancellation will apply to the next period. For example, if you purchase a monthly subscription, you may cancel that subscription at any time during any month of the subscription, and the subscription will be cancelled as of the following month. You will not receive a refund for the current billing period, except in the event of a defective product (as set out in section 6 below), or as otherwise set out out in these Terms. With respect to magazine or news content subscriptions on Google Play Newsstand, you will continue to receive Content and updates (if applicable) of the relevant subscription during the remainder of the current billing period. After that billing period ends, your access to previously delivered magazine issues will not be affected by the cancellation, but your access to paid news content will terminate at the end of the billing period during which your subscription is cancelled. With respect to music subscriptions, you will continue to have access to Music Subscription Content (as defined in Section 7 below) during the remainder of the current billing period; however, your access to Music Subscription Content will terminate at the end of the billing period during which your subscription is cancelled. Additional refund policies for music and periodicals are set out in sections 7 and 10 below, respectively.

Price Changes. When you purchase a subscription, you will initially be charged at the rate applicable at the time of your agreement to subscribe. If the price of the subscription increases later, Google will notify you. The increase will apply to the next payment due from you after the notice, provided that you have been given at least 10 days’ prior notice before the charge is made. If you are given less than 10 days’ prior notice, the price increase will not apply until the payment after the next payment due.

Declining Price Changes. If you do not wish to pay the increased price for a subscription, you may cancel the subscription in the manner described in the Google Play help center and you will not be charged further amounts for the subscription, provided you have notified us before the end of the current billing period. In some cases where the Provider increases the price of a subscription Google may cancel your subscription unless you agree to re-subscribe at the new price. If your subscription is cancelled and you later decide to re-subscribe, you will initially be charged at the then current subscription rate.

6. Rights and Restrictions

License to Use Content. Following payment of the applicable fees for Content, you will have the non-exclusive right, for the period selected by you in the case of a purchase for a rental period, and in other cases for as long as Google and the applicable copyright holder have rights to provide you that Content, to download or stream, in each case, solely as expressly permitted by Google via the Google Play user interface and subject to the restrictions set out in the Terms and associated policies, copies of the applicable Content to your Devices, and to view, use, and display the Content on your Devices or as otherwise authorized by Google as part of the Service for your personal, non-commercial use only. All rights, title and interest in Google Play and Content not expressly granted to you in the Terms are reserved by Google and its licensors.

Violation of License Terms. If you violate any of the terms and conditions of the Terms, your rights under this license will immediately terminate and Google may terminate your access to Google Play, the Content and/or your Google account without refund to you.

No Public Performance. You must not display (in part or in whole) the Content as part of any public performance or display even if no fee is charged (except where such use would not constitute a copyright infringement or violate any other applicable right). Use of a tool or feature provided as an authorized part of Google Play (for example, “Social Recommendations”, as defined in the Music terms below) is permitted, provided that as you use the tool or feature as specifically permitted and only in the exact manner specified and enabled by Google.

Sale, Distribution or Assignment to Third Parties. You may not sell, rent, lease, redistribute, broadcast, transmit, communicate, modify, sublicense or transfer or assign any Content or your rights to Content to any third party without authorization, including with regard to any downloads of Content that you may obtain through Google Play. Use of any tool or feature provided as an authorized part of Google Play (for example, “Social Recommendations”) shall not violate this provision so long as you use the tool as specifically permitted and only in the exact manner specified and enabled by Google.

Capturing of Streams. You may not use Google Play or any Content in conjunction with any stream-ripping, stream capture or similar software to record or create a copy of any Content that is presented to you in streaming format.

Sharing. You may not use Content as part of any service for sharing, lending or multi-person use, or for the purpose of any other institution, except as specifically permitted and only in the exact manner specified and enabled by Google (for example, through “Social Recommendations”).

Security Features. You may not attempt to, nor assist, authorise or encourage others to circumvent, disable or defeat any of the security features or components, such as digital rights management software or encryption, that protect, obfuscate or otherwise restrict access to any Content or Google Play. If you violate any security feature, you may incur civil or criminal liability.

Proprietary Notices. You may not remove any watermarks, labels or other legal or proprietary notices included in any Content, and you may not attempt to modify any Content obtained through Google Play, including any modification for the purpose of disguising or changing any indications of the ownership or source of Content.

Use of Android Apps. You must use apps from Google Play in accordance with the Google Play Business and Program Policies which are in place from time to time, the current version of which can be found at http://play.google.com/about/android-developer-policies.html

Defective Content. Once Content is available to you through your account, you should check the Content as soon as reasonably possible to ensure that it downloads or streams correctly (as applicable) and performs as stated, and notify us as soon as reasonably possible if you find any errors or defect. In the case of Android apps, you should contact the developer concerning any defects or performance issues in the apps, as described in the Google Play help center. In the case of Content other than apps, subject to any limitations in the additional terms for the specific Content below, you may cancel purchases you have made from Google Play to Google if Google Play does not perform as stated with respect to that purchased Content, and Google will provide either a replacement Content (if available) or a refund of the purchase price.

If Google provides you a refund, the refund of your purchase price shall be your sole remedy.

If Google issues a refund or credit, it is under no obligation to issue the same or similar refund in the future.

In the case of subscription purchases, Google may grant a refund for the entire term or a partial refund for issues not received in the remaining term of subscription.

Removal or Unavailability of Content. Subject to the Terms, Content that you purchase will be available to you through Google Play for the period selected by you, in the case of a purchase for a rental period, and in other cases as long as Google has the right to make such content available to you. In certain cases (for example, if Google loses the relevant rights, discontinues a service or Content is discontinued, breaches applicable terms or the law), Google may remove from your Device or cease providing you with access to certain Content that you have purchased. Google will provide you with reasonable prior notice of any such removal or cessation. If you are not able to download a copy of the Content before such removal or cessation, then Google will offer you either (a) a replacement of the Content if possible or (b) a refund of the price of the Content. If Google issues you a refund, the refund of your purchase price shall be your sole remedy.

Effect of Refunds. If a refund of the purchase price of Content for any reason is issued to you, you will no longer have the right to access the relevant Content.

Select, Copy and Paste. Select, copy and paste functions may be available for some text-based Content, and you must use these features within the prescribed limits and only for personal non-commercial purposes.

Multiple Accounts. If you have multiple Google accounts with different user names, in some cases you may transfer Content out of an account and into another account, provided you are the owner of each such account and provided Google has enabled a feature of the relevant service allowing such transfers.

Limits on access on Devices. Google may from time to time place limits on the number of Devices and/or software applications you may use to access Content (for more information, please visit the Help link for the relevant Content within Google Play). Google may record and store the unique device identifier numbers of your Devices in order to enforce such limits.

Dangerous Activities. None of the Services or Content are intended for use in the operation of nuclear facilities, life support systems, emergency communications, aircraft navigation or communication systems, air traffic control systems, or any other such activities in which case the failure of the Services or Content could lead to death, personal injury, or severe physical or environmental damage.

Changes to these Terms.

If the Terms change, you will be asked to accept new terms before you next purchase Content. Once you have accepted the new terms, they will apply to your use of all Content (including Content you have purchased in the past) and all subsequent purchases, until we notify you of further changes.

If you refuse to accept the updated terms then you will not be able to buy any further Content through Google Play, and the latest version of the Terms that you accepted will continue to apply to your use of Content. In this case we will, if we are able to do so, give you a reasonable period of time in which to download a copy of any Content you have previously bought from Google Play to your Device, and you may continue to view that copy of the Content on your Devices in accordance with the last version of the Terms that you accepted.

After that time has expired, you will not be given a further opportunity to download the Content you have previously bought and it is possible that you will no longer be able to use Google Play to access or use the Content you have already bought or related support services. If this happens, Google will offer you either a replacement of the Content, or a refund of the price of the Content, which will be your sole remedy. To access or use the Content you have already bought or related support services, you may also need to create a new account.

7. Music on Google Play

Introduction. Google Play includes certain music-related products and services, which are described in greater detail below and defined as “Music Products”, “Music Subscription Content”and “Music Locker Services”.

Music Products; Music Subscription Content. The Google Play store allows you to browse, preview, stream, purchase, download, recommend and use a variety of digital music and music-related content such as music files, music video files, previews, clips, artist information, user reviews, professional third-party music reviews and other digital content (“Music Products”). Certain Music Products may be accessible to you by purchasing (or receiving a free trial of) a subscription to a music subscription service made available via Google Play (“Music Subscription Content”). Music Products may be owned by Google or its third-party partners and licensors and may contain watermarks or other embedded data. For clarity, all Music Products constitute “Products” as defined in Section 1 above.

Stored Content. You can use Google Play to store digital content (such as music files, related metadata and album art) in Music Storage through the Music Software, as each is defined below (“Stored Content”). For the avoidance of doubt, “Music Products” do not include Stored Content. Stored Content may include both files that you upload directly to Music Storage and/or files that Google “scans and matches” to files stored locally on your Device.

Music Locker Services. Google Play may provide you with access to (a) server space that you can use to store music and associated data files, including Music Products and Stored Content (“Music Storage”) and/or (b) software applications (including web, desktop and mobile applications) and related services that allow you to upload, manage, access and play music through Music Storage (“Music Software”). Music Storage and Music Software are collectively referred to in these Terms as the “Music Locker Service”. For clarity, you may be given access to Stored Content and Music Subscription Content through the same user interface.

Use of Music Locker Services. By storing Music Products and Stored Content in Music Storage, you are storing a unique copy of such content and requesting Google to retain it on your behalf and to make it accessible to you through your Google account. By using the Music Locker Services, you are requesting that Google make all of the necessary functions and features of the Music Locker Services available to you in order to facilitate your use of Music Products and Stored Content. Additionally, by accessing or using Music Products and Stored Content through the Music Software, you are initiating and performing the corresponding functions on Google’s servers, together with any related steps necessary to achieve them, through the Music Locker Services. You understand that Google, in performing the required technical steps at your direction to provide you with the Music Locker Services, may (a) transmit Music Products and Stored Content over various networks and in various media and (b) make such changes to Music Products and Stored Content as are necessary to conform and adapt it to the technical requirements of connecting networks, devices, services or media. You confirm and warrant to Google that you have the necessary rights to store in Music Storage any Stored Content that you direct Google to upload or store in Music Storage, and to instruct Google to perform the actions described in this section.

Cancelling a Music Purchase; Refunds. You have the right to cancel each purchase of a Music Product from Google (including a music subscription) for a refund within 7 working days of the day after that Music Product becomes available for you to download or stream, provided that, with respect to music subscription free trials: (i) you may cancel your subscription at any time during a free trial period (as set out in section 5 above) and (ii) you will not have the foregoing 7-day cancellation right once the paid portion of your subscription has commenced. Once you download or stream any Music Product that you purchase, you no longer have the right to cancel your purchase of that Music Product (unless the Music Product is defective). If Google grants to you a refund for a music subscription, the refund amount will be pro-rated to reflect remaining term of the subscription. Following Google’s provision of a refund to you, you will no longer have the right to access the applicable Music Product.

Other Google Subscription Services. You may receive access to a Google Play music subscription as part of a subscription to another Google product; additionally, you may receive access to other Google subscription products as part of a Google Play music subscription. The details of your access to such other Google subscription products will be presented to you before you complete your music subscription purchase. Your use of Google Play and any Google Play music subscription product is governed solely by these Terms, and not the terms of any other Google product, including any other Google product through which you receive access to a Google Play music subscription.

Social Recommendations. When you purchase Music Products, you may be given the opportunity to share all or a portion of the Music Products to your profile on Google+ or other Google-approved social networks or online destinations, as determined by Google in its sole discretion (“Social Recommendation”). Your use of Social Recommendations shall be subject to the Terms and any other terms and conditions applicable to the social networks or online destinations to which you share such Social Recommendations. Google may impose limitations on your Social Recommendations. For example, Google may render the Music Product associated with any Social Recommendation as a limited-length preview rather than a full-length play.

Rights to Stored Content. You retain any rights that you already hold in Stored Content. For the avoidance of doubt, Stored Content is not subject to the license grant to Google in the section of the Google Terms of Service titled “Your Content in our Services.”

Geographic Restrictions. The Music Locker Services and Music Products are currently available only in some countries. You agree that you will not present any false, inaccurate or misleading information in an effort to misrepresent yourself as a resident of a supported country, and you will not attempt to circumvent any restrictions on access to or availability of the Music Locker Services or Music Products.

Compliance With Settings. You must observe and comply with any settings or parameters set by Google or a copyright holder in connection with Music Products. For example, Google or the copyright holders may correct errors in Music Products, add additional features or change the security features or regional availability of the Music Products. Where these changes are made, the Music Products may automatically update.

Third-Party Provisions. Notwithstanding anything to the contrary in these Terms, the third parties who license their musical or other content to Google as Music Products or for other use in connection with the Google Play store (including Providers in the case of Agency Sales) are intended third party beneficiaries under these Terms solely with respect to the specific provisions of these Terms that directly concern their content (“Third-Party Provisions”), and solely for the purpose of enabling such third parties to enforce their rights in such content. For the avoidance of doubt, nothing in these Terms confers a third-party beneficiary right upon any party, with respect to any provision that falls outside the Third Party Provisions, which includes but is not limited to any provisions or agreements incorporated by reference, or that may be referenced without incorporation, in these Terms.

Third-Party Software and Data. Information regarding third-party software (including open source) and data in the Music Locker Services can be obtained at the following location:http://music.google.com/about/thirdparty.html.

Licensing Partners. If you are interested in learning more about some of the partners we work with to bring you music on Google Play, please visit this page.

8. Books on Google Play

Privacy Policy for Books. The Google Play Privacy Policy for Books describes how we treat personal and certain other information generated by your use of Content that is books (“Books Content”).

Device Requirements. For information on the system requirements including what Devices are compatible with the Service and the purchase of and access to Books Content, please look at http://support.google.com/mobile/?p=books_devices.

Updates to Books Content. Google or the copyright holders of Books Content may update such Books Content and change digital rights settings for such Books Content from time to time. For example Google or the copyright holders may correct errors in the Books Content or may add additional features, or may change the security features for the Books Content. Where these changes are made the Books Content that you see will automatically update, except where you have downloaded a copy of the Books Content to a Device.

Cancellation. In addition to your rights to cancel if you have a defective Product, as set out in section 6, you have the right to cancel the contract for each purchase or rental of a Book Content from Google for a refund within a period of 7 working days beginning with the day after that Book Content becomes available for you to read, except for rentals of Books Content for a 24-hour period, to which the cancellation right does not apply. Following Google’s provision of a refund to you, the transaction will be reversed, and you will no longer have the right to access the applicable Book Content.

Additional Restrictions. The sale of Books does not provide any promotional use rights in any Book.

9. Movies and TV Shows on Google Play

Introduction. Google Play includes certain video services, which are defined as the “Video Services”. In the Terms, Content made available for purchase through the Video Services are “Video Content”.

Cancellation. You can cancel your purchase of unwatched Video Content and get a refund of the purchase price within 7 working days of your purchase. Requests for refunds for any other reason must be directed through the form in the Google Play help center. Google reserves the right to approve or deny refund requests after 7 working days at its sole discretion.

Purchase Options. When you order Video Content through the Service, you may either (i) rent the Video Content for viewing an unlimited number of times during the period of time specified on the transaction page displayed at the time of your payment (“Viewing Period”) and noted in your confirmation email (“Rental Video Content”) or (ii) where available, purchase the Video Content for storage in a digital locker and for viewing and unlimited number of times as long as the Video Content is available in the digital locker (“Locker Video Content”).

Viewing Periods – Rentals. Pausing, stopping, or rewinding a Rental Video Content will not extend your applicable Viewing Period for that Rental Video Content. Each item of Rental Video Content may have a different Viewing Period and the Viewing Period will be shown to you before you order it.

Viewing Periods – Purchases. Each Locker Video Content will be available for unlimited viewing for as long as Google is able to maintain the rights to continue providing you that Locker Video Content (“Locker Period”). Pausing, stopping, or rewinding an item of Locker Video Content will not extend the Locker Period. Each item of Locker Pay Content may have a different Locker Period.

Viewing requirements. You agree to watch each Video Content only within territories within which Google makes the relevant Video Content available for viewing. You may view Video Content when (1) online, with an internet connection and logged onto your Google account or (2) offline and viewing from a previously authorized device. You must be online to authorize a device for viewing Video Content.

Device Limits – Rentals. For each purchased Rental Video Content, you may watch such Rental Video Content on only one Device at a time (either online or on an authorized offline Device).

Viewing Limits – Purchases. For Locker Video Content, (1) you may view only one stream of each Locker Video Content at a time, (2) you may view up to 3 streams of Locker Video Content from your locker at a time, (3) you may authorize up to 5 Devices for offline playback of Locker Video Content at a time and to authorize additional devices, you must de-authorize one of those 5 Devices, (4) you may only authorize the same Device three times in any 12 month period and de-authorize the same Device twice in any 12 month period, (5) you may only de-authorize a total of 2 Devices for offline playback every 90 days, and (6) you may authorize no more than 3 Google accounts on the same Device.

10. Periodicals on Google Play Newsstand

This section applies to sales of periodicals (magazines and news content) on Google Play Newsstand, and not to periodical content provided within other Android apps.

Reductions for Print Subscribers. Some Providers of periodicals may allow you to purchase a subscription of periodical Content on Google Play at a reduced rate if you are already a print subscriber. If you cancel your print subscription or that periodical or your print subscription expires and you do not renew it, your reduced rate subscription of that Content on Google Play will be cancelled automatically.

Refunds. Where you are granted a refund, Google may issue a refund for the entire term or grant a partial refund for Content not received in the remaining term of a subscription. Following Google’s provision of a refund to you, you will no longer have the right to access the applicable issues of the relevant periodical Content delivered during the refunded period, or if a partial refund is given, any Content of the relevant periodical not yet received. If periodical Content is no longer available on Google Play (for example, if a title goes out of business or is sold to another publisher that does not provide periodicals on Google Play), Google will give you a refund (which may be a full refund for the current period of the subscription or a partial refund for Content not yet received in the current period).

Information Google Shares with Periodical Publishers. If you purchase a periodical subscription of any length on Google Play, Google may share your name, email address, mailing address and a unique identifier with the periodical’s publisher. As a subscriber to the periodical, Google may also share your reading history within the periodical with the publisher of that periodical. Google has agreed with the periodical publisher that the periodical publisher will use this information in accordance with the publisher’s privacy policy. You will be provided the opportunity to opt out of any communications from the publisher that do not relate to the subscription you are purchasing, and to opt out of marketing communications from third parties, at the time you purchase your subscription. If you purchase a single issue of a magazine on Google Play, Google may provide your postal code to the magazine’s publisher. We also provide periodical publishers with sales information on periodical purchases.

Verifying Print Subscriptions. If you are accessing a subscription on Google Play Newsstand through an existing print subscription from that periodical’s publisher, we may ask a third party service provider to verify your print subscription with the periodical publisher, and we may ask you for certain information relating to your print subscription in order to do so. Google will use this information in accordance with the Google Privacy Policy.

Cancellation. In addition to your rights to cancel if you have a defective Product, as set out in section 6, please see section 5 for your right of cancellation in relation to periodical subscriptions.