Thursday, January 10, 2013

How-to Install Google AdMob 6.x into Android Apps

STEP 1: Register yourself as a user at http://admob.com . Login and create a site

admob in android app
  













admob in android app


setting site in admob


setting site in admob


setting site in admob


setting site in admob -publisher ID


STEP 2: Download the AdMob SDK currently SDK 6.1.0

make money from your android app


make money from your android app

STEP 3: Add an External JAR (library) in the project.

Copy GoogleAdMobAdsSdk-6.1.0.jar into libs

adding admob on android app


adding admob on android app

image



STEP 4: Additional details in the AndroidManifest.xml

Open your AndroidManifest.xml and add this lines to the <application> properties;

<activity android:name="com.google.ads.AdActivity"
   android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

Next, add these  <uses-permission>

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
 

And the meta-data attributes;
<meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />

And the complete AndroidManifest.xml;
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="net.kerul.peribahasa"
    android:versionCode="7"
    android:versionName="1.07" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/icon"
        android:label="@string/app_name" >
        <activity
            android:name=".PeribahasaActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            
        </activity>
          <activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
            
    </application>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <meta-data android:value="true" android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" />
</manifest>




STEP 5: Adding the AdView widget in the screen

   1: <TableRow
   2:     android:id="@+id/tableRow2"
   3:     android:layout_width="match_parent"
   4:     android:layout_height="wrap_content" >
   5:     <com.google.ads.AdView
   6:         xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
   7:         android:id="@+id/ad"
   8:         android:layout_width="fill_parent"
   9:         android:layout_height="wrap_content"
  10:         ads:adSize="SMART_BANNER"
  11:         ads:adUnitId="738a44d913034b9f"
  12:         />    
  13: </TableRow>


STEP 6: Adding the adView in the source code.

   1: public class PeribahasaActivity extends Activity implements OnClickListener{
   2:     protected EditText txtsearch;
   3:     protected Button btnocr, btnkamus, btnsearch,btncadang;
   4:     //protected Button btnpaste,btntaipinput;
   5:     protected WebView webview1;
   6:     protected String serverurl;
   7:     protected AdView adView;
   8:     /** Called when the activity is first created. */
   9:     @Override
  10:     public void onCreate(Bundle savedInstanceState) {
  11:         super.onCreate(savedInstanceState);
  12:         setContentView(R.layout.main);
  13:         
  14:         //admob widget
  15:         adView = (AdView)findViewById(R.id.ad);
  16:         adView.loadAd(new AdRequest());
 



























































































































Saturday, November 3, 2012

nice looking calendar



 http://www.dansshorts.com/skins/dansshorts/assets/images/calendar.png



 <style>


</style>




<div class="post-date">

nice font [ hand writting like ]

<style>


</style>

<h2 class=".post-title">
<a title="Permanent Link to Creating Snippets in Eclipse" rel="bookmark" href="/post/creating-snippets-in-eclipse">

Creating Snippets in Eclipse

</a>
</h2>

Friday, October 5, 2012

db executeUpdate , return boolean instead of int {smart code}

public boolean dbDelete(sql){
 return ( db.executeUpdate(sql) ) > 0 ;
}

timer task

final Timer timer = new Timer();
timer.schedule(new TimerTask(){
@override
 public void run(){
 // write your business here
timer.cancel();
}
},5000);

Saturday, June 9, 2012

how to write jquery plugin


   <script>

(function($){
    $.fn.extend({
        //plugin name - animatemenu
        animateMenu: function(options) {

            var defaults = {
                animatePadding: 60,
                defaultPadding: 10,
                evenColor: '#ccc',
                oddColor: '#eee',
            };
            
            var options = $.extend(defaults, options);
        
            return this.each(function() {
                  var o =options;
                  var obj = $(this);              
                  var items = $("li", obj);
                  
                  $("li:even", obj).css('background-color', o.evenColor);             
                  $("li:odd", obj).css('background-color', o.oddColor);                 
                  
                  items.mouseover(function() {
                      $(this).animate({paddingLeft: o.animatePadding}, 300);
                    
                  }).mouseout(function() {
                      $(this).animate({paddingLeft: o.defaultPadding}, 300);
                    
                  });
            });
        }
    });
})(jQuery);
    
    </script>
   
   
   
   
    <script type="text/javascript">
  
        $('#menu').animateMenu({animatePadding: 30, defaultPadding:10});

    </script>

Monday, April 2, 2012

ImageServlet

package com.mehconsulting.servlets;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// The following import just gives us an example image to use for this example:
import com.mehconsulting.samples.SampleImage;

public class ImageServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
   
    public ImageServlet() {
        super();
    }

    protected void doGet(
        HttpServletRequest request, HttpServletResponse response
        ) throws ServletException, IOException {
       
        // Not used in our simple example - see text.
        // String imageName = request.getParameter("imageName");
       
        // For this example, just create our input stream from our sample byte array:
        ByteArrayInputStream iStream = new ByteArrayInputStream(SampleImage.sampleImage);
       
        // Determine the length of the content data.
        // In our simple example, I can get the length from the hard-coded byte array.
        // If you're getting your imaqe from a database or file,
        // you'll need to adjust this code to do what is appropriate:
        int length = SampleImage.sampleImage.length;
       
        // Hard-coded for a GIF image - see text.
        response.setContentType("image/gif");
        response.setContentLength(length);
       
        // Get the output stream from our response object, so we
        // can write our image data to the client:
        ServletOutputStream oStream = response.getOutputStream();
       
        // Now, loop through buffer reads of our content, and send it to the client:
        byte [] buffer = new byte[1024];
        int len;
        while ((len = iStream.read(buffer)) != -1) {
            oStream.write(buffer, 0, len);
        }
       
        // Now that we've sent the image data to the client, close down all the resources:
        iStream.close();
       
        oStream.flush();
        oStream.close();