Tuesday 4 April 2017

Fragments in Android

A fragment represents a conduct or a part of user interface in an activity. You can integrate more than one fragment in a single activity to build a multi-pane UI and reuse a fraction in multiple activities. you may consider a fragment as a modular phase of an activity, which has its personal lifecycle, receives its very own enter events, and which you may upload or dispose of even as the interest is walking (kind of like a "sub interest" that you may reuse in exclusive sports).

Following are crucial points about fragment

  • A fragment has its very own layout and its own behaviour with its personal life cycle callbacks.
  • You may add or do away with fragments in an interest whilst the interest is strolling.
  • You may integrate multiple fragments in an unmarried hobby to construct a multi-plane UI.
A fraction can be utilized in multiple activities.
  • Fragment life cycle is closely associated with the life cycle of its host interest which means when the pastime is paused, all the fragments available in the hobby will also be stopped.
  • A fraction can put into effect a behaviour that has no person interface aspect.
  • Fragments were added to the Android API in Honeycomb model of Android which API version eleven.
  • You create fragments via extending Fragment elegance and you can insert a fraction into your hobby layout by way of affirming the fragment inside the hobby's format document, as a <fragment> detail.
  • Prior to fragment introduction, we had a difficulty because we will display only a single hobby on the display screen at one given factor in time. So we had been not capable of divide device display and control extraordinary components one by one. However with the introduction of fragment we got greater flexibility and removed the difficulty of having a single activity on the display screen at a time. Now we will have a single pastime however every interest can incorporate of more than one fragments in order to have their own format, occasions and entire life cycle.
Right here is the listing of techniques which you can to override for your fragment magnificence

1 A fraction can be utilized in multiple activities.
  • Fragment life cycle is closely associated with the life cycle of its host interest which means when the pastime is paused, all the fragments available in the hobby will also be stopped.
  • A fraction can put into effect a behaviour that has no person interface aspect.
  • Fragments were added to the Android API in Honeycomb model of Android which API version eleven.
  • You create fragments via extending Fragment elegance and you can insert a fraction into your hobby layout by way of affirming the fragment inside the hobby's format document, as a <fragment> detail.
  • Prior to fragment introduction, we had a difficulty because we will display only a single hobby on the display screen at one given factor in time. So we had been not capable of divide device display and control extraordinary components one by one. However with the introduction of fragment we got greater flexibility and removed the difficulty of having a single activity on the display screen at a time. Now we will have a single pastime however every interest can incorporate of more than one fragments in order to have their own format, occasions and entire life cycle.
Right here is the listing of techniques which you can to override for your fragment magnificence
1)      onAttach():The fragment example is related to an interest example. The fragment and the hobby aren’t always fully initialized. Generally you get on this approach a connection with the interest which makes use of the fragment for similarly initialization paintings.

2)      onCreate(): The device calls this technique when developing the fragment. You have to initialize critical components of the fragment which you need to keep when the fragment is paused or stopped, then resumed.

3)      onCreateView(): The system calls this callback while it is time for the fragment to attract its person interface for the primary time. to draw a UI on your fragment, you need to go back a View issue from this technique that is the foundation of your fragment's format. you may return null if the fragment does no longer provide a UI.

4)      onActivityCreated(): The onActivityCreated() is referred to as after the onCreateView() method whilst the host hobby is created. Activity and fragment example have been created in addition to the view hierarchy of the activity. At this point, view may be accessed with the findViewById() method. Example. on this approach you may instantiate objects which require a Context object

5)      onStart(): The onStart() technique is known as once the fragment gets visible.

6)      onResume(): Fragment turns into lively.

7)      onPause(): The device calls this technique because the first indication that the person is leaving the fragment. this is generally where you need to dedicate any modifications that must be endured beyond the modern-day person session.

8)      onStop(): Fragment going to be stopped by using calling onStop()

9)      onDestroyView():Fragment view will smash after call this technique

10)  onDestroy(): onDestroy() known as to do very last smooth up of the fragment's state however no longer assured to be referred to as by using the Android platform.
 How to use Fragments?

·         This involves wide variety of simple steps to create Fragments.
·         To begin with determine what number of fragments you need to apply in an activity. as an instance permit's we need to apply  fragments to address landscape and portrait modes of the device.
·         Next based totally on number of fragments, create instructions to be able to amplify the Fragment class. The Fragment class has above noted callback capabilities. you could override any of the functions based totally to your requirements.
·         Corresponding to each fragment, you'll need to create layout files in XML record. Those files may have format for the defined fragments.
·         Eventually adjust activity document to outline the actual good judgment of changing fragments based totally to your requirement.
Forms of Fragments

·         Basically fragments are divided as three ranges as proven underneath.

·         Single body fragments− single frame fragments are using for hand keep devices like mobiles, right here we can show best one fragment as a view.

·         List fragments − fragments having special listing view is called as list fragment

·         Fragments transaction− The usage of with fragment transaction. We are able to flow one fragment to any other fragment.

Wednesday 29 March 2017

Mobile Search Engine Optimization

Mobile Optimization

Mobile optimization is the process of ensuring that visitors who access your website from mobile devices have knowledge of optimized for the device.

What is mobile Optimization

Every year people spend maximum time on their mobile devices and tablets, however several websites still are not designed to account for various screen sizes and load times. Mobile optimization takes a look at page speed, website structure, website design, and additional to create certain you are not unwittingly turning mobile guests or visitors away.
Web application development company

Mobile SEO Best Practices


If your website is already optimized for search engines, there are only some additional things that you can think about when you optimizing for mobile.
Page Speed:
Because of hardware and property problems, page speed is even a lot of necessary for mobile users than desktop users. Beyond optimizing pictures, you will need to minify code, leverage browser caching, and reduce redirects.

Website design for mobile


Mobile devices are simplifying and revolutionizing the ways in which websites are designed. "Above the fold" not has which means during a world whenever we have a tendency to scroll endlessly
 Android Application development company

Optimize titles and Meta descriptions


Remember that you are working with less screen space when a user searches using a mobile device. To show off your best work in SERPS (Tools for Keyword Checking on Google or Yahoo Search engine), be as concise as possible (without sacrificing the quality of the information) when creating URLs, titles, and Meta descriptions.

Optimize for local search


If your business has a local element, keep in mind to optimize your mobile content for local search. This includes standardizing your name, address, and signal and as well as your town and state name in your website's data.

Mobile site configuration


Probably the most necessary decision you will build once fitting a website is deciding whether or not you wish to use a responsive, dynamic serving, or separate website configuration. Everyone has its advantages and disadvantages. Google prefers responsive design however supports all 3 choices as long as you have got set them up properly.
Responsive web design            
Responsively designed websites use CSS3 media queries to serve an equivalent content to mobile and desktop users using a fluid grid and a useable design to automatically depend to the size of a user's screen.
 Mobile application development company


Responsive designed use media queries to focus on the layout supported screen dimension, resolution and orientation. For example, you might use the subsequent CSS to instruct browsers a way to show content for a screen that is 420 or fewer pixels wide:

Final thoughts

Sure, do paid search to get visibility in Google smart-phone search; however do not forget to try to mobile SEO (Search engine optimization) for additional visibility. These steps — target on fix mobile-friendly errors, core ranking, do mobile keyword research and content creation, do apps store optimization and apps indexing, and use AMP (Accelerated Mobile Pages) — will help bring more organic traffic to your content from mobile searchers.


Monday 27 March 2017

About Intents in Android

 Android application development company

Intents:
Intents are asynchronous message which allow application components to request functionality from other Android components.
The dictionary meaning of Intent is Intention or purpose. So it can be described as the intention to do action.
Android intent is the message that is passed between components such as content providers, activities, broadcast recievers, services etc.
Android Intents are mainly used to:
·                     start a service
·                     dial a phone call
·                     Broadcast a message
·                     Display a list of contacts
·                     Display a web page

The LabeledIntent is the subclass of android.content.Intent class.
An intent can contain data via a Bundle. This data can be used by the receiving component.
In Android the reuse of other application components is a concept known as task. An application can access other Android components to achieve a task.
Starting activities or services:
To start an activity you have to use a method startActivity().This method is defined the Context object which Activity extends.
The following code demonstrates how you can start activity via intent.

Intent i = new Intent (this,Login.class);
startActivity(i);

Activities which are started by other android activities are called sub-activities. To start a service via intents, use the startService(Intent) method call.

Types of Android Intents:
There are two types of Intents in android which are as follows:
·         Implicit Intent
·         Explicit Intent

Implicit Intent:
These Intents do not name a target and the field for the component name is left blank. Implicit Intents are also used to activate components of other activities.
for example-
Intent i= new Intent();
i.setAction(android.content.Intent.ACTION_VIEW);
i.setData(ContactsContracts.CONTENT_URI);
startActivity(i);
Explicit Intent:
Explicit intent going to be connected intenal world of application. Explicit Intent specifies the components. In such case,intent provides the external class to be invoked.
For example-
Intent i= new Intent();
startActivity(this,First.class));
Let's see a simple example of Intent that take from one activity to another activity.
First Activity XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_horizontal"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingBottom="@dimen/activity_horizontal_margin"
        android:gravity="center_horizontal"
        android:background="#bcbaba">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?      android:attr/textAppearanceSmall"
                android:text="Email"
                android:id="@+id/textView9"
                android:layout_marginBottom="4dp"
                android:textSize="20sp"
                android:textColor="#ffffff" />
            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#fff"
                android:layout_weight="1">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/imageView3"
                    android:background="@drawable/email_icon"
                    android:layout_gravity="left|center_horizontal" />
                <EditText
                    style="@style/signupEditText"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textPersonName"
                    android:ems="10"
                    android:id="@+id/edtEmail"
                    android:layout_centerVertical="true"
                    android:layout_centerHorizontal="true"
                    android:hint="Email"
                    android:gravity="center_vertical"
                    android:paddingTop="5dp"
                    android:paddingBottom="5dp" />
            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:paddingTop="5dp">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:text="Password"
                android:id="@+id/textView10"
                android:layout_marginBottom="4dp"
                android:textSize="20sp"
                android:textColor="#ffffff" />
            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="#fff"
                android:layout_weight="1" >
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/imageView9"
                    android:background="@drawable/password_icon"
                    android:layout_gravity="left|center_horizontal" />
                <EditText
                    style="@style/signupEditText"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:ems="10"
                    android:id="@+id/edtPassword"
                    android:layout_centerVertical="true"
                    android:layout_centerHorizontal="true"
                    android:hint="*******"
                    android:gravity="center_vertical"
                    android:inputType="textPassword"
                    android:paddingTop="5dp"
                    android:paddingBottom="5dp" />
            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal">
        </LinearLayout>
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal">
            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/btnSignIn"
                android:onClick="onClick"
                android:layout_gravity="center_horizontal"
                android:gravity="center"
                android:background="#fff"
                android:layout_marginTop="25dp"
                android:text="LOGIN"
                android:textColor="#238996"
                android:textSize="18sp" />
        </LinearLayout>
    </LinearLayout>


Second Activity XML:
<?xml version="1.0" encoding="utf-8"?>
<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"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.tecorb.eat_we_go.Second"
    android:background="#c5bebe">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Welcome"
        android:id="@+id/textView6"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="195dp"
        android:textStyle="bold"
        android:textSize="30sp"
        android:textColor="#1d1717" />
</RelativeLayout>

First.java
package com.example.tecorb.eat_we_go;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class First extends AppCompatActivity {
    EditText edtEmail,edtPassword;
    Button btnSignIn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first);
        edtEmail = (EditText) findViewById(R.id.edtEmail);
        edtPassword = (EditText) findViewById(R.id.edtPassword);
        btnSignIn=(Button)findViewById(R.id.btnSignIn);
        btnSignIn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                startActivity(new Intent(getApplicationContext(), Second.class));
            }
        });
    }
}
In above example, there are two xml activity in which first is our main and login activity in which we take two edit text for email and password and a login button to submit the data by which on click we reach at the other activity where we take an edit text and show welcome as a text.

With the help of java we write code and by intent we connect two activities as first activity with the second.