Search This Blog

Friday 31 January 2014

Starting Developing application with android Studio is fun or Pain !

Android launched new android development environment  few months ago, is known as android studio based on Intelli J IDEA. This development tool is in early stage of preview. You can make android application using this tool too.

What android studio right away offer -

  •         Gradle-based build support.
  •         Android-specific refactoring and quick fixes.
  •         Lint tools to catch performance, usability, version compatibility and other problems.
  •         ProGuard and app-signing capabilities.
  •         Template-based wizards to create common Android designs and components.
  •         A rich layout editor that allows you to drag-and-drop UI components, preview layouts on  multiple screen configurations, and much more.
  •         Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud Messaging and App Engine as server-side components.
See android developer guide installing and setup environment. Android Studio is a promising tool which will going to be more stable and useful in coming release. I just goes through google and find out benefits and constraint of Intelli J IDEA, Android studio

Benefits 


  •   All benefit which you read in first heading, will get you right away
  •  You can import your existing android project inside android studio
  •   Look modern compare to eclipse, more responsive  and integrated plugin like ADB and sdk Manager.

 

Should we go for it?

 

Yes go for it and learn it, but do not use fully as its in early stage of development and little unstable. With few more release you can directly start development. There is no place in which android studio lack compare to eclipse

 

See some screenshot of android studio while creating an new project


Home Android Studio

First Project Screen


Wednesday 29 January 2014

Super User Android : How to do changes in system app in rooted device

If you rooted your device than you have complete control on how it looks and works. You can modify setting look and feel, you can remove setting option completely. In rooted device you got access to system app which control whole android device.

This concept run around that every application (i.e Settings, Contact etc) has one apk installed in one specific directory called /system/app. What we need to do just grab the source code for which we want to modify and create your own apk and finally replace it with existing system apk. After rebooting device your new changes will reflect on android device.

Lets do it in steps. I did it for Setting.apk. I grab the source code of Setting application from Git Hub directory. and i did some change and then replace it.

Step 1) Grab source code of application in which you want to change. Make changes and prepare one APK.

Step 2)  Now we need to install APK into system directory
  
  • Connect device with ADB command and push apk to  SD card
            $ adb push  /Setting.apk  /sdcard/  
  • Enter into shell
            $ adb shell
  • Now switch to super user
             $ su
  • Grab write permission to push apk
             $ mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
  • push your apk to root
             $ cat /sdcard/Setting.apk > /system/app/Setting.apk
  • Remount /system partition back to READ-ONLY and reboot device
             $ mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system
             $ exit


Done !! you had changes in to android o.s configuration. Leave your comments


 

Tuesday 28 January 2014

Google Glass application development : How and why to start being an android developer


Google Glass is a wearable computer with an optical head-mounted display (OHMD) that is being developed by Google in the Project Glass research and development project, with a mission of producing a mass-market ubiquitous computer.Google Glass displays information in a smartphone-like hands-free format, that can communicate with the Internet via natural language voice commands.

How to start development of Google Glass application

This is ambitious project of Google and Google has marketed well among user. The best thing about Google is it kept as simple as possible for developer. Existing android developer can male Google Glass application easily. Google Android provide GDK(Glass Development Kit) which can be added as add-on  to Android SDK.



You will feel like working for android in same environment for Google Glasses. Its exceptionally similar until you go for testing your application.


Developer need Google Glasses in real to test and deploy. First link to start development is Start Google Glass Development

How to distribute Google Glass application

Google provide Glass Play Store  to deploy and upload Google Glass application for commercially and non commercially uses.

Why to work Google Glass application? What is scope ?

Even being criticize by some, Google Glasses have tremendous  opportunity in Medical, Education and Gaming. Virtual Reality and Augmented Reality are concept which can be best capitalize in real life using Google Glass so called wearable computer. For developer, Its a new challenge with full of scope. If you are already develop android application then jump to make an application for Google Glasses.

Friday 24 January 2014

Hack trick : Endless ViewPager example in android

I was trying to implement endless ViewPager, Suddenly a thought strike my mind and develop this tutorial which damn simple to integrate with any kind of adapter. I just showed here with ViewPager.

MainConcept


Return infinite value in getCount() and then take your own position to display values.


Support


Its support in every version of android. Look at output



So lets have a look of code which lead to an endless ViewPager in android application

Step 1) Take one array of Image which will be show in ViewPager elements. Change your MainActivity code to as follows

package com.fragmentpageradapter;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;

public class MainActivity extends FragmentActivity {
    ViewPager mPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mPager = (ViewPager) findViewById(R.id.frame);
        mPager.setOffscreenPageLimit(1);
        mPager.setAdapter(new EndLessAdapter(this, mImageArray));
    }

    private int[] mImageArray = { R.drawable.a, R.drawable.a1, R.drawable.a2,
            R.drawable.a3 };
}


Step 2) Create one simple layout for MainActivity which contain one ViewPager

<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=".MainActivity" >

    <android.support.v4.view.ViewPager
        android:id="@+id/frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerInParent="true" >
    </android.support.v4.view.ViewPager>

</RelativeLayout>

Step 3) Create one PagerAdapter name EndLessAdapter

package com.fragmentpageradapter;

import android.os.Parcelable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;

public class EndLessAdapter extends PagerAdapter {

    FragmentActivity activity;
    int imageArray[];

    public EndLessAdapter(FragmentActivity act, int[] imgArra) {
        imageArray = imgArra;
        activity = act;
    }

    public int getCount() {
        return Integer.MAX_VALUE;
    }

    private int pos = 0;

    public Object instantiateItem(View collection, int position) {

        ImageView mwebView = new ImageView(activity);
        ((ViewPager) collection).addView(mwebView, 0);
        mwebView.setScaleType(ScaleType.FIT_XY);
        mwebView.setImageResource(imageArray[pos]);

        if (pos >= imageArray.length - 1)
            pos = 0;
        else
            ++pos;

        return mwebView;
    }

    @Override
    public void destroyItem(View arg0, int arg1, Object arg2) {
        ((ViewPager) arg0).removeView((View) arg2);
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == ((View) arg1);
    }

    @Override
    public Parcelable saveState() {
        return null;
    }

}

What make it endless

    public int getCount() {
        return Integer.MAX_VALUE;
    }

Now you will start unrelated position so implement your own way of attaching data to ViewPager child.

    private int pos = 0;

    public Object instantiateItem(View collection, int position) {

        ImageView mwebView = new ImageView(activity);
        ((ViewPager) collection).addView(mwebView, 0);
        mwebView.setScaleType(ScaleType.FIT_XY);
        mwebView.setImageResource(imageArray[pos]);

        if (pos >= imageArray.length - 1)
            pos = 0;
        else
            ++pos;

        return mwebView;
    }


Memory Issue : Because ViewPager keep one child at each side so this solution work without any memory issue. If you are going to implement same solution for ListView then you may get memory issue as all row kept inside memory


Android News and source code