Monday 30 June 2014

How to Install Android L on Your Nexus Device.

Now, you have to install the correct drivers for your Nexus 5 and/or Nexus 7. Here is what you need to do:

After connecting the device to the PC, power the Nexus off.
Turn on your device in fastboot mode; the key combination for your device is either volume down + power (2013 Wi-Fi Nexus 7, codenamed flo/razor) or volume up + volume down + power (Nexus 5, codenamed hammerhead).
From Device Manager (Computer -> Properties -> Device Manager) identify your device (it will show up with a yellow exclamation mark icon).
Right click on it, select Update Driver Software and then select Browse my computer for driver software.
Select Let me pick from a list of device drivers on my computer.
From Have Disk... option manually install the android_winusb.inf driver (in my case, its location is C:\Program Files (x86)\Android\android-sdk\extras\google\usb_driver). Accept any prompts that may appear.
Select the Android ADB Interface option when given the option. Accept any prompts that may appear.


Step 1: Connect Your Phone to Your PC

This is a simple, yet important step. Make sure the USB cable that you're using to connect your phone to your PC is in good condition. 

Step 2: Download the Preview Images from Google
Google has made the Android L preview images available on a special developers website, but that doesn't mean the general public can't download them too.

From your Windows PC, click this link to head to the download page. From here, scroll down a bit and click the download link next to the Nexus 5 (GSM/LTE) "hammerhead" entry (or Nexus 7 (WiFi) "razor" if you are doing this for your Nexus 7).



Step 3: Configure Nexus Root Toolkit
By now, you should have arrived at the Nexus Root Toolkit's main screen. But before you get to flashing the images, you'll need to make sure your device drivers are in order. Right up top, click the button that says Full Driver Installation Guide to begin.

Step 5: Flash the Preview Images
At this point, the only thing left to do is install the Android L preview images. From the NRT main screen, click Flash Stock + Unroot to begin.


On the following screen, tick the box next to Other/Browse up top, and make sure that I downloaded a factory image myself that I would like to use instead is selected as the second option.
               


A file browser window will pop up at this point. Just navigate to your Downloads folder and select the hammerhead...tgz file that you downloaded earlier (or the razor...tgz file for the Nexus 7).


Shortly after that, you'll be asked to enter an MD5 number to verify the file's integrity. Copy the following text, then paste it into the field in that window and click OK:

5a6ae77217978cb7b958a240c2e80b57 (this will be different for the Nexus 7)
                          

At this point, the file will be verified and extracted, so give it a minute or two. When it's done, a window will appear that summarizes the install options you've selected. Click OK here to begin flashing the update, making sure that your phone doesn't get disconnected from your PC during this process.


The process takes at least 5 minutes to complete, so don't freak out if it seems to get hung up on one aspect of the install. When it's finished, you'll get a confirmation dialog that instructs you to Press any key to exit, so do that. Close out any further dialog boxes, as you're done with the Nexus Root Toolkit.



For some reason, Android L doesn't seem to want to boot up if you're still connected to your PC. So disconnect your USB cable at this point, and give your phone at least 5 minutes to finish booting.


All Done!
Your device is now running the Android L preview. Be aware that you may encounter bugs due to it being in an earlier stage of development. 

Friday 27 June 2014

The use of getViewTypeCount() and getItemViewType() in Adapter .

If we need to show different type of view in list-view then its good to use  getViewTypeCount() and getItemViewType() in adapter instead of  toggling a vieVIEW.GONE and VIEW.VISIBLE can be very expensive task inside getView() which will affect the list scroll.
So first of all you need to create different layouts for each type of view.

 1.simple textview.

 2.Row with image and text.


3.Simple row.


4.Row with two view .

So first need to create 4 different xmls for different row type.

Ho to use this getViewTypeCount() and getItemViewType() in adapter?
1) getViewTypeCount() :-
Returns the count of different type of views. Here we are having four different type of views so this method will return count as 4.
@Override
public int getViewTypeCount() {
return 4;
}
2) getItemViewType() :-
@Override
public int getItemViewType(int position) {

 if (mArrayList.get(position) instanceof TextModel) {
    return VIEW_TYPE_ROW_1;
 } else if (mArrayList.get(position) instanceof HeaderModel) {
    return VIEW_TYPE_ROW_2;
 } else if (mArrayList.get(position) instanceof ImageModel) {
    return VIEW_TYPE_ROW_3;
 } else {
    return VIEW_TYPE_ROW_4;
 }
}
Now Do Work inside getView(...) method first we determine the type of view by calling getItemViewType(..) method, which will return the type to be inflated as shown below.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder.MapViewHolder mapViewHolder = null;
Holder.HdrViewHolder hdrViewHolder = null;
Holder.GridViewHolder gridViewHolder = null;
Holder.BrthViewHolder brthViewHolder = null;
int type = getItemViewType(position);
if (type == VIEW_TYPE_ROW_1) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.raw_one, null);
mapViewHolder = new Holder().new MapViewHolder();
mapViewHolder.cardViewGmap = (CardView) convertView
.findViewById(R.id.list_raw_map);
convertView.setTag(mapViewHolder);
} else {
mapViewHolder = (MapViewHolder) convertView.getTag();
}
GooglePlaySmallCard cardGmap = new GooglePlaySmallCard(mContext);
cardGmap.setId("gplaysmall");
// Set card in the cardView
mapViewHolder.cardViewGmap.setCard(cardGmap);
} else if (type == VIEW_TYPE_ROW_2) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.raw_three, null);
hdrViewHolder = new Holder().new HdrViewHolder();
hdrViewHolder.cardshd = (CardView) convertView
.findViewById(R.id.list_carddemo_shadow_layout);
convertView.setTag(hdrViewHolder);
} else {
hdrViewHolder = (HdrViewHolder) convertView.getTag();
}
Card shcard = new Card(mContext);
// Create a CardHeader
CardHeader header = new CardHeader(mContext);
// Set the header title
header.setTitle(mContext.getString(R.string.demo_header_basetitle));
shcard.addCardHeader(header);
// Hidden shadow
shcard.setShadow(true);
hdrViewHolder.cardshd.setCard(shcard);
} else if (type == VIEW_TYPE_ROW_3) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.raw_two, null);
gridViewHolder = new Holder().new GridViewHolder();
gridViewHolder.gdcardView = (CardView) convertView
.findViewById(R.id.list_carddemo_Gplay1);
gridViewHolder.gdcardView1 = (CardView) convertView
.findViewById(R.id.list_carddemo_Gplay2);
convertView.setTag(gridViewHolder);
} else {
gridViewHolder = (GridViewHolder) convertView.getTag();
}
GplayCard gcard = new GplayCard(mContext);
gridViewHolder.gdcardView.setCard(gcard);
gridViewHolder.gdcardView1.setCard(gcard);
} else if (type == VIEW_TYPE_ROW_4) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.list_demo_raw, null);
brthViewHolder = new Holder().new BrthViewHolder();
brthViewHolder.bthcardView = (CardView) convertView
.findViewById(R.id.list_carddemo_cardBirth);
convertView.setTag(brthViewHolder);
} else {
brthViewHolder = (BrthViewHolder) convertView.getTag();
}
GoogleNowBirthCard birthCard = new GoogleNowBirthCard(mContext);
birthCard.setId("myId");
brthViewHolder.bthcardView.setCard(birthCard);
}
return convertView;
}

 Hope this is useful to someone.

Copy and share your useful data from Google chrome browser to your application in android.

Here In this blog I explain that how to copy and share your useful data from chrome browser in android. 1) How to show your applic...