Saturday, February 2, 2013

Google Plus Integration




In the days, Social networking covers whole the worlds. And  Be the part of it we all know about Google+.

As a developer i have to said that, "humble requirement comes from the client side too , that in every application they wants to connect/reach with more people with adding social networking functionalities". After all it is good marketing strategies without applying any charges. It’s an audience marketers cannot ignore.

In this Race, why google not increase they dominion.
It boasts a cool 250 million users! And this number is sure to grow very quickly as Google is making a Google+ account mandatory for all Gmail users. 

Ohhh, its the too much information, i should turn towards the main focus.

Most Google+ users are mobile, not desktop users (The Google+ Developers Blog)

After a long time Google release Latest Google+ (plus) API for Android Developers as Publically.

It's just a simple no need to take much effort or spend time beyond it for apply it in you pretty application.


The Google+ platform for Android has the following Requirements... 

  • A physical device to use for developing and testing because Google Play services cannot be installed on an emulator or ( spend so much time for do that but not officially allowed ).
  • The latest version of the Android SDK, including the SDK Tools component. The SDK is available from the Android SDK Manager.
  • Your project to compile against Android 2.2 (Froyo) or higher.(here in my case I have run in 4.0)


The Google Play services SDK:


1.  Launch Eclipse and select Window > Android SDK Manager or run android from the command  line.


2. Scroll to the bottom of the package list and select Extras > Google Play services.

3. The package is downloaded to your computer and installed in your SDK environment at
  <android-sdk-folder>/extras/google/google_play_services. (Check out it is available in folder.) 

          It's enough for our requirement...


Stop before Go ahed , After much Test n run , i put the guideline below:

From here myths aries in mind after integrate All social API in our project. As far we are integrate it and for basic requirement we need to….. 

  • create Project name OR register it on etc. developer site.
  • Create OAuth 
  • Create and generate certification etc… etc.
The Google Innovation aries With Google+ new API. No need to follow tedious procedure for "register","OAth" and "certificate".

Time to run Google+ plus sample app:

The sample is an Eclipse project that you can run on your device as follows:

  1.  Select File > Import > Android > Existing Android Code Into Workspace and click Next.
  2.  Select Browse..., enter <android-sdk-folder>/extras/google/google_play_services/samples/plus, and click Finish.
  3. Select Browse..., enter <android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar
  4. Select Browse..., enter<android-sdk-folder>/extras/android/compatibility or support/v4/android-support-v4.jar
  5. Copy the jar files ( you can also pick the Library as well but instead of it. i suggest that pick only jar file form there )
  6. Put jar in your Project's "libs" folder After only right click on .jar >build Path>Add To Build Path 
  7. (don't forget to make "libs" folder if you have't because you have Latest AVD 21 or  Updated it requires "libs"  and  your jar file with build automatically no need to build or don't Select Add External Jars it generate problems some times.

    Now Google+ API is ready for run in device.

    Some preeminent KEY features, Have to remind you.
    •   Google+ official Application installation required in your device,(not at Don't Worry API will  suggest you for that)
    •  This will automatically take the default google User of you device.(default user " Google Account synch in you device")

    Here i have to share some complication which faced during implementation.
        
    1) when pressed "sign in" button Tost generate "internal error":.

    You get this two lines in SignInActivity.

    private static final String PLUS_WRITE_MOMENThttps://www.googleapis.com/auth/plus.moments.write";

    static final String[] SCOPES= {Scopes.PLUS_PROFILE,PLUS_WRITE_MOMENT};
    ...
    plusClient = new PlusClient(this, this, this, SCOPES);

    above you can see SCOPES [array] is pass in plusClient ,error aries for that resion. only i remove "PLUS_WRITE_MOMENT" from the SCOPES problem solved.

     2) During sharing  post/picture/video/link :

    default you see the share screen take a deep link automatically so, doesn't see the option for upload video, photo and etc.

    But you want to directly see this screen for upload Photo , video , Links etc. 

    Remove Uri and .setContent from the intent.
    Uri thumbnail = Uri.parse(getString(R.string.plus_deep_link_metadata_thumbnail_url));
                    Intent shareIntent = PlusShare.Builder.from(this)
                                .setText(mEditShareText.getText().toString())
                                .setType("text/plain")
                                .setContent(ShareActivity.TAG,getString(R.string.plus_deep_link_metadata_title),
                                getString(R.string.plus_deep_link_metadata_description),
                                        thumbnail)
                                .getIntent();

    3)Plus one activity:

     If you want to implement "OnPlusOneClickListener"

    private static final String URL = "http://www.gmail.com/";
     mPlusOneStandardButton.initialize(mPlusClient, URL,new OnPlusOneClickListener() {
    @Override
    public void onPlusOneClick(Intent intent) {
    // TODO Auto-generated method stub
    startActivityForResult(intent, PLUS_ONE_REQUEST_CODE);
    }
    });

    Finally Dont forget to add permission in your own project manifest and Look at list one time manifest of Google+. API
        
    You can split and use API as your necessity Like only share , PlusOneButton …. 


    More firm references… "how it methods and perimeters works... you can  go with.....



    1 comment:

    Anonymous said...

    Hey, nice site you have here! Keep up the excellent work!

    Google App Integration Chennai