Monday, 29 September 2014

How to add Ads in android.

 There are so many ads for mobile application especially in android. Some of them are

1. Admob
2. Airpush
3.Startapp
4.LeadBolt
5. Mopub and so on.

I used all.The best one is top 3 ad networks. Previously Admob provided SDK but now it has been integrated with Google play services so that you don't need to use separate sdk for Admob.

How to use Admob?

Go to apps.admob.com. Create an account and give your app name and it provides you an ad unit.

Use which ad type you are going to display.  Since other networks are providing a clean documentation when you logged in. But Admob you need to surf and for new update, you can't find a clear updates and user miss some important keys in admob which I noticed. Here I am discussing about this.

Admob provides two types.

1. Banner adview

2. Interestitial ads.

If you choose interestitial ads, you can use like this.

import com.google.android.gms.ads.InterstitialAd;

public class MainActivity extends Activity {
private InterstitialAd interstitial; // Declare interstitial ads here.


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
           interstitial = new InterstitialAd(MainActivity.this);
        // Insert the Ad Unit ID
        interstitial.setAdUnitId("<Ad unit id>");

          AdRequest adRequests = new AdRequest.Builder().build();
   interstitial.loadAd(adRequests);
   interstitial.setAdListener(new AdListener() {
       @Override
       public void onAdLoaded() {
           super.onAdLoaded();
           interstitial.show();

       }

       @Override
       public void onAdFailedToLoad(int errorCode) {
           super.onAdFailedToLoad(errorCode);

       }

   });
 
       }
     

  For Banner ads:

       AdView adView = (AdView) this.findViewById(R.id.adView);
    
        AdRequest adRequest = new AdRequest.Builder()

        // Add a test device to show Test Ads..comment for real app when launching
        // .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
         //.addTestDevice("CC5F2C72DF2B356BBF0DA198")
                .build();

        // Load ads into Banner Ads
        adView.loadAd(adRequest);

    in xml:

       <com.google.android.gms.ads.AdView
         android:id="@+id/adView"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         ads:adUnitId="<ads id>"
                         ads:adSize="BANNER"/>

 important to note that, you need to declare for xml as:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto" // these line is most needed in top of the xml when you are using adview inside layout.
................
<Adview> here
>
</LinearLayout>

 and in manifest file, these lines are to be added

 <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
 
        <activity
            android:name="com.google.android.gms.ads.AdActivity"        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
 

You can run and test it and it works.



Monday, 23 June 2014

My first experience with seminar in Android as Chief Guest -October 2012

Had  conducted two days of  workshop about Android. Though many workshop conducted, but the first workshop about Android was at Mahendra Engineering college on October  5th and 6th.
It was nice as principal, HOD were very interacted and taken care and arrangements were made to us as Chief Guest to the college were perfect. 

Me and my colleague Sivaputra invited as Chief Guest to the college. It's a great honour and immense pleasure for us. The first session handled by him the whole day where I taken care of handling next day.Nearly 200 students participated in the workshop.  Handling nearly 200 students by two of them was a challenging one where students should not get bored. Already well prepared by both to have some fun in between also to interact with students to their place. Representative  also taken care of us by arranging necessary which needed. College taken care the whole two days for accommodation and everything.  We given our best by providing students a valuable and sharing knowledge to them.  







Sunday, 22 December 2013

Increase Whatsapp trail period

Now whatsapp is increasing by more users since it has more advantage like an instant messenger which deliver your message immediately you send it and receive message immediately you sent message.It also allow you to send multimedia message such as voice record,video,video record,audio,image etc., but we all know every whatsapp users are entitled to 1 year free trial period before the person will be subsequently paying after trail ends.

I strongly recommend doing this when your whatsapp is a day to expire but you can still use it now. Faster enough the better it is.

Below will explain how to extend whatsapp usage.

Its available for the following devices.

 — S40 Java C3-00 / C3-01 / X2-00 / X2-01 / X3-02 / 201 / 300 / 302 / 303 / 306 / 311
— Symbian: X7 · E6 · N8 · C6 · C7 · E7 · 500 · 600 · 603 · 700 · 701 · 808
— S60 5th edition: Nokia 5800 · Nokia 5530 · Nokia 5230 · Nokia 5233 · Nokia 5235 · Nokia N97 · Nokia N97 mini · Nokia X6 · Nokia X5-01 · Nokia C6 · Nokia C5-03 · Samsung i8910 Omnia HD · Sony Ericsson Satio · Sony Ericsson Vivaz · Sony Ericsson Vivaz Pro
— S60 3rd edition: Nokia 5700 · Nokia 6110 · Nokia 6120 · Nokia 6121 · Nokia 6124 · Nokia 6700 · Nokia 6290 · Nokia E51 · Nokia E63 · Nokia E66 · Nokia E71 · Nokia E90 Communicator · Nokia N76 · Nokia N81 · Nokia N81 8GB · Nokia N82 · Nokia N95 · Nokia N95 8GB · Nokia 5320 · Nokia 5630 · Nokia 5730 · Nokia 6210 · Nokia 6220 · Nokia 6650 fold · Nokia 6710 Navigator · Nokia 6720 · Nokia 6730 · Nokia 6760 Slide · Nokia 6790 Surge · Nokia C5 · Nokia E52 · Nokia E55 · Nokia E72 · Nokia E73 · Nokia E75 · Nokia E5 · Nokia N78 · Nokia N79 · Nokia N85 · Nokia N86 8MP · Nokia N96 · Samsung GT-i8510 · Samsung GT-I7110 · Samsung SGH-L870 · Samsung SGH-G810 · Samsung SGH-iNNN

Note: Since there are so many devices,some device may also support which is not in this list.Just try it.

Step 1:
Open your whatsapp and press Option > About > Account Info > Option > Delete Account

Step 2:
A page will be displayed telling you to enter your mobile number and telling you what will happen. 
 Delete All Your Whatsapp Service Payment Information

Step 3:
Then press continue after you enter your phone number and follow the next steps to complete deletion.

Step 4:
Now trial is gone but you are no more on whatsapp. Read on.
Open whatsapp back and register as normal as you do before by entering and confirming your phone number.

Step 5:
After successful registration, you get one more year free. Check the status again as explained above in the first place.

Step 6:
Finished.. all you need to do to get rid of the trial.





Tuesday, 17 December 2013

Game physics with Liquid Fun in android

Liquid Fun

LiquidFun is a 2D rigid body simulation library for games. Programmers can use it in their games to make objects move in realistic ways and make the game world more interactive

Physics Engine:

A system for generating procedural animations deals with physical process especially collisions. Doesn't
include rendering code.

Supporting Platforms :

Android

OSX

Windows

Particle Characteristics:

Color

Size

Position

Velocity

Strength

Creating a particle:


   b2ParticleDef pd;
   pd.flags = b2_elasticParticle;
   pd.color.Set(0, 0, 255, 255);
   pd.position.Set(i, 0);
   int tempIndex = m_world->CreateParticle(pd);


Particle Groups:

Create and destroy many particles at once.
Add Properties as Rotational angle,velocity, strength

Creating Particle Groups:

Create a shape
Create particular group definition object
Create the group

A sample code to demonstrate about creating and destroying particle:

Group creation code:

   b2ParticleGroupDef pd;
   b2PolygonShape shape;
   shape.SetAsBox(10, 5);
   pd.shape = 
   pd.flags = b2_elasticParticle;
   pd.angle = -0.5f;
   pd.angularVelocity = 2.0f;
   for (int32 i = 0; i < 5; i++)
   {
      pd.position.Set(10 + 20 * i, 40);
      pd.color.Set(i * 255 / 5, 255 - i * 255 / 5, 128, 255);
      world->CreateParticleGroup(pd);
      m_world->CreateParticleGroup(pd);
   }

Particle destroy:

   b2ParticleGroup* group = m_world->GetParticleGroupList();
   while (group)
   {
      b2ParticleGroup* nextGroup = group->GetNext(); // access this before we destroy the group
      m_world->DestroyParticleGroup(group);
      group = nextGroup;
   }

Source: 








Wednesday, 4 December 2013

Android Kitkat 4.4 features

Android kitkat 4.4 released on October 31st with special features.

1. Low memory support even in 512 Ram. This includes new Api ActivityManager.isLowRamDevice() which let's your app's behaviour to match target device's memory.

2. NFC through Host Card Emulation: Android 4.4 introduces Host card Emulation where it's based on Smart card that uses contactless protocol for transmission.

3.Sms ProviderThe new APIs use  new SMS_Deliver intent to allow app developers to route messages through the user’s default messaging app, making the cross-app experience seamless.

4.New Sensor Modes and Connectivity Hardware Sensor Batching is a new optimization that dramatically reduce power consumption during ongoing sensor activities.

5. Improved Security: Allows Antivirus Scanner api,control over individual app permissions.  KitKat also improves upon the cryptographic algorithms by adding support for two additional algorithms.

6.Chromium WebviewAndroid 4.4 includes a completely new implementation of WebView that's based on Chromium.Chromium WebView provides broad support for HTML5, CSS3, and JavaScript. It supports most of the HTML5 features available in Chrome for Android 30. It also brings an updated version of the JavaScript Engine (V8) that delivers dramatically improved JavaScript performance.

7.Screen Recording Android 4.4 adds support for screen recording and provides a screen recording utility that lets you start and stop recording on a device that's connected to your Android SDK environment over USB. It's a great new way to create walkthroughs and tutorials for your app, testing materials, marketing videos etc.,If your app plays video or other protected content that you don’t want to be captured by the screen recorder, you can useSurfaceView.setSecure() to mark the content as secure.

Tuesday, 23 July 2013

Volley in android

Volley is a library and also powerful tool that makes networking for Android apps easier and most importantly, faster.It's an alternative of AsyncTask.
It manages the processing and caching of network requests and it saves developers valuable time from writing the same network call/cache code again and again.You can easily load thumbnail images for your ListView from the network in parallel.
Clone the volley project from

 https://github.com/adamrocker/volley

Advantages:
    Volley automatically schedule all network requests. It means that Volley will be taking care of all the network requests your app executes for fetching response or image from web.
    Volley provides transparent disk and memory caching.
    Volley provides powerful cancellation request API. It means that you can cancel a single request or you can set blocks or scopes of requests to cancel.
    Volley provides powerful customization abilities.
    Volley provides Debugging and tracing tools

There are 2 main classes:
1. Request queue
2. Request



private void getServices(String url) {
//        JSONObject reqBody = new JSONObject();
        Map<String,String> params = new HashMap<String,String>();
        if (url.equals(URL_SUCCESS)) {
            try {
                params.put("id", "Demo");
                params.put("output", "json");
                url = addParamsToUrl(url, params);
                volleyRequestQueue = Volley.newRequestQueue(this);
                volleyRequestQueue.add(new JsonObjectRequest(Method.GET, url, null, new MyResponseListener(), new MyErrorListener()));
              
              
            } catch (Exception e) {
                Log.e("ErrorListener", e.getLocalizedMessage());
            }
        } else {
            params.put("level", "1");
            url = addParamsToUrl(url, params);
            volleyRequestQueue = Volley.newRequestQueue(this);
            volleyRequestQueue.add(new JsonObjectRequest(Method.GET, url, null, new MyResponseListener(), new MyErrorListener()));
        }
    }

class MyResponseListener implements Listener<JSONObject> {

        @Override
        public void onResponse(JSONObject response) {
            MainActivity.this.jsonObj = response;
            try {
                JSONObject result = MainActivity.this.jsonObj.getJSONObject("Result");
                String timestamp = result.getString("Timestamp");
                MainActivity.this.resultTxt.setText(new Date(Long.parseLong(timestamp.trim())).toString());
            } catch (Exception e) {
                Log.e("ErrorListener", e.getLocalizedMessage());
            }
        }
    }


and the class error.


class MyErrorListener implements ErrorListener {

        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e("ErrorListener", error.getCause() + "");
            if (error.getCause() != null) {
                Log.e("ErrorListener", error.getLocalizedMessage());
            }
            MainActivity.this.resultTxt.setText(error.toString());
            volleyRequestQueue.cancelAll(this);
        }
    }

Saturday, 8 June 2013

The Way The Life goes..

I am here to say nothing new about Life but just want to color it that i want to share.

It’s my thought how i look Life and how it can be and based on my thoughts which includes for me and not intended to hurt anyone.

Some says Life is dull, looks not colorful,shaded etc., everyone’s Life is like a book,don't skip the page to see what's the end result.Enjoy every moment, sometimes book may contain error correct it,instead don't throw it. Without hot and rain, you can’t see rainbow. Make it so colorful and fly high to touch the sky.

If you are worry, just go to the beach sit and watch the beauty of sea, see the beauty of leaves,nature,singing of birds. Every time sea hits the rock and rise. similarly problem also, destroy those problems and arise and don't withdraw, try as you can.Happiness always surrounds us. utilizing is in our hands.   

Next comes  purest form and meaningful is friendship. All humans cant be same. Every humans may vary.If all characters are equally given by HIM, life will also get bored. Some may reserved, talkative, fighting,angry mood,sad mood etc., but everyone have a good nature,but environment and surroundings make  to change.
Similarly the dear one who shows more angry or irritated just get rid of that place or be silent, more arguments will take more unwanted topics to continue and it will make a gap between the value of friendship.

Making others happy is a gift and similarly should not be responsible for others sorrow. It will hurt them a lot. We may forget but the dear one who got hurt will not say but pain will remain always.Sometimes polite speech and silence is also a best one to defeat a person who hurts you. Don't ever never care what others say or spread gossip about you.just spread a smile.

Once Mother Theresa went in a street and met a stranger who is in upstairs.She looked up and asked sir,will you please donate a fund to the orphanage if you can. Stranger simply splitted on her hands and said, go this what i have. Mother Theresa smiled and said in a polite way that you have given for me, yet there are so many children who still suffering. On hearing this, stranger's heart felt very bad and came from upstairs and hold her legs and asked to forgive him.

No one can't be a perfect! but can be changed with extend. 

Life is to enjoy.In this short and just temporary life, make friends and avoid arguments and angry!!  Cute fights can be done, and it should not get hurt to that person.

If mistake is not on your side, don't worry and be bold on your side and if your mistake is on your side, don't hesitate to say sorry!! 

Ever never change your character for anyone.Be what you are and don't intimate others. One of the main problem arises is confusion between heart and mind. Don't mismatch your love to think in mind and work in heart. Solve it at right time and right place. keep surroundings happy.

Four letter word meaningful and worth.

Love and  live in Life with smile forever!! :)




Do the best what you can

Be the first how should be

Leave the rest if you cant

Keep smiling always...................