Wednesday, 11 December 2013

Android tutorial Downloads


Complete list of android tutorials for download
https://drive.google.com/file/d/0B1mP6EVd-7HJLU9TSnRsMFNNdTg/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJN0JwakJLZmY0Y2c/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJNFRxN1VqUHB2aW8/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJNVJUY2Y2bzZaeFk/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJOHFxTmVveS14R2s/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJOHd2RS0wbHJvMG8/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJQWY5TklXbmZDaU0/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJQkNhUnRGNG9RU3c/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJRTA5ZkxseWw1MGs/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJT25HTUVrUmp2ZFE/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJTDlnMHRWY204Njg/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJU0N2eGFSSnZJRlE/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJUjQ3d3BNLXhvemc/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJUjUtcGhwWmRhd2c/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJUkZMdFhtMEpTQjg/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJVHU3OXF0bGNTSDg/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJVzJhYWwtT2pVTnc/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJWW8wY21QWWMzczg/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJX20tOERjQk5sUmM/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJXzVJTC1xTFlzVTQ/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJYzNZRE9yc3FTMms/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJZzl6MHQ2djUwR0E/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJaXhhYk03ZkZhbE0/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJb1RPbHB3WWVuZGc/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJbEJfU200NHdZVEU/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJbW1ZQWY4LW80cWc/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJcXNackdqdkJwUjA/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJdF9fZ1FSczFwSlU/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJeGZrdVU5U0paWVk/edit?usp=sharing
https://drive.google.com/file/d/0B1mP6EVd-7HJeUlLSS1wSXE0d0k/edit?usp=sharing

Tuesday, 10 December 2013

Android Animation

Click here to acess pdf of this POST Lionel® - Shop Trains Shop the Lionel Online Store Today. 10% off All Orders With Promo Code CJN10P. package com.sawan;

import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class HelloAnimationActivity extends Activity implements OnClickListener {
    /** Called when the activity is first created. */
Button start,stop;
AnimationDrawable animationDrawable=null;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        start= (Button) findViewById(R.id.button1);
        stop=(Button) findViewById(R.id.button2);
        start.setOnClickListener(this);
        stop.setOnClickListener(this);
    }
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.button1:
startanimation();
break;
case R.id.button2:
stopanimation();
default:
break;
}
}
private void stopanimation() {
// TODO Auto-generated method stub
animationDrawable.stop();
}
private void startanimation() {
// TODO Auto-generated method stub
ImageView img=(ImageView) findViewById(R.id.imageView1);
BitmapDrawable image1=(BitmapDrawable) getResources().getDrawable(R.drawable.splash1);
BitmapDrawable image2=(BitmapDrawable) getResources().getDrawable(R.drawable.splash2);
BitmapDrawable image3=(BitmapDrawable) getResources().getDrawable(R.drawable.splash3);

int resonableduration=500;
animationDrawable=new AnimationDrawable();
animationDrawable.addFrame(image1, resonableduration);
animationDrawable.addFrame(image2, resonableduration);
animationDrawable.addFrame(image3, resonableduration);

img.setBackgroundDrawable(animationDrawable);
animationDrawable.setVisible(true,true);
animationDrawable.start();




}
}

Download
click to begin
1.2MB .zip

Android Services



package com.mywebservices;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;

import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;

import org.json.JSONException;
import org.json.JSONObject;

import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;

public class JSONFunctions {




public static JSONObject getJSONfromURL(String url){
InputStream is = null;
String result = "";
JSONObject jArray = null;

//http post
   try{
           HttpClient httpclient = new DefaultHttpClient();
           HttpPost httppost = new HttpPost(url);
           HttpResponse response = httpclient.execute(httppost);
           HttpEntity entity = response.getEntity();
           is = entity.getContent();
         

   }catch(Exception e){
           Log.e("log_tag", "Error in http connection "+e.toString());
   }
 
 //convert response to string
   try{
           BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
           StringBuilder sb = new StringBuilder();
           String line = null;
           while ((line = reader.readLine()) != null) {
                   sb.append(line + "\n");
           }
           is.close();
           result=sb.toString();
   }catch(Exception e){
           Log.w("log_tag", "Error converting result "+e.toString());
   }
 
   try{
   
            jArray = new JSONObject(result);          
   }catch(JSONException e){
           Log.w("log_tag", "Error parsing data "+e.toString());
   }
 
5% OFF All Lenovo ThinkPad's    return jArray;
}



 public static Bitmap downloadFile(String fileUrl){
 Bitmap bmImg = null;
         URL myFileUrl =null;        
         try {
              myFileUrl= new URL(fileUrl);
         } catch (MalformedURLException e) {
           
              e.printStackTrace();
         }
         try {
              HttpURLConnection conn= (HttpURLConnection)myFileUrl.openConnection();
              conn.setDoInput(true);
              conn.connect();
              //int length = conn.getContentLength();
              InputStream is = conn.getInputStream();
           
              bmImg = BitmapFactory.decodeStream(is);
           
         } catch (IOException e) {
              e.printStackTrace();
         }
         return bmImg;
    }


public static JSONObject getJSONfromURL(String url,JSONObject inputjson){
InputStream is = null;
String result = "";
JSONObject jArray = null;

//http post
   try{
           HttpClient httpclient = new DefaultHttpClient();
           HttpPost httppost = new HttpPost(url);
           String inputjsonstring=inputjson.toString();
           StringEntity inEntity = new StringEntity(inputjsonstring);
           inEntity.setContentType("text/plain;charset=UTF-8");
           //entity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"text/plain;charset=UTF-8"));
           httppost.setEntity(inEntity);
         
         
           HttpResponse response = httpclient.execute(httppost);
           HttpEntity entity = response.getEntity();
           is = entity.getContent();
                 

   }catch(Exception e){
           Log.e("log_tag", "Error in http connection "+e.toString());
   }
 
 //convert response to string
   try{
           BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
           StringBuilder sb = new StringBuilder();
           String line = null;
           while ((line = reader.readLine()) != null) {
                   sb.append(line + "\n");
           }
           is.close();
           result=sb.toString();
   }catch(Exception e){
           Log.w("log_tag", "Error converting result "+e.toString());
   }
 
   try{
   
           jArray = new JSONObject(result);          
   }catch(JSONException e){
           Log.w("log_tag", "Error parsing data "+e.toString());
   }
 
   return jArray;
}


// http://localhost:8888/allsetbuy/login?cmd=register
void sdf(SQLiteDatabase db){



}

}

Download
click to begin
1.2MB .zip

Android Content Providers


DownloadDemo
click to begin
1.2MB .zip
DownloadContacts
click to begin
1.2MB .zip

Hotels.com

Android Wifi



package com.example.wifi;

import java.util.Iterator;
import java.util.List;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.google.ads.Ad;
import com.google.ads.AdListener;
import com.google.ads.AdRequest;
import com.google.ads.InterstitialAd;

public class MyWiFi extends Activity implements OnClickListener, AdListener {

// class provides the primary API for managing all aspects of Wi-Fi
// connectivity
// list of configured networks,currently active Wi-Fi network,
WifiManager wifiManager;

BroadcastReceiver broadcastReceiver;

Button wifibutton;
private static final String LOG_TAG = "InterstitialSample";



/** The interstitial ad. */
private InterstitialAd interstitialAd;

/** The button to reload the interstitial. */
private Button loadButton;

/** The button to show the interstitial. */
private Button showButton;

public String a152a434feea793;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wifi);
interstitialAd = new InterstitialAd(this,a152a434feea793);

// Set the AdListener.
interstitialAd.setAdListener(this);

// Get a reference to the reload button. This button will load an
// interstitial ad.
loadButton = (Button) findViewById(R.id.loadButton);

// Get a reference to the show button. The button will start disabled,
// but
// will be enabled when the interstitial ad is loaded. After it is
// shown,
// it will be disabled again.
showButton = (Button) findViewById(R.id.showButton);
showButton.setText("Interstitial Not Ready");
showButton.setEnabled(false);

// Set the onClickListener for the buttons.
loadButton.setOnClickListener(this);
showButton.setOnClickListener(this);

// Setup UI
TextView setText = (TextView) findViewById(R.id.wifi_Text_View);
wifibutton = (Button) findViewById(R.id.wifi);

wifibutton.setOnClickListener(this);

registerReceiver(broadcastReceiver, new IntentFilter(
WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));

broadcastReceiver = new BroadcastReceiver() {

@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
wifibutton.setText("Wifi Clicked");
List<ScanResult> myResults = wifiManager.getScanResults();
Iterator<ScanResult> scanResult = myResults.iterator();
while (scanResult.hasNext())
;
Toast.makeText(MyWiFi.this, "enterd into WiFi Zone",
Toast.LENGTH_LONG).show();
wifiManager.getConfiguredNetworks();

}
};

}

@Override
public void onClick(View view) {
// If the load button was clicked, load an interstitial ad. Otherwise,
// if
// the show button was clicked, show the interstitial.

wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifiManager.startScan();

if (view == loadButton) {
// Disable the show button until the new ad is loaded.
showButton.setText("Loading Interstitial...");
showButton.setEnabled(false);

// Load the interstitial ad. Check logcat output for the hashed
// device ID
// to get test ads on a physical device.
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
interstitialAd.loadAd(adRequest);
} else if (view == showButton) {
// Disable the show button until another interstitial is loaded.
showButton.setText("Interstitial Not Ready");
showButton.setEnabled(false);

// Show the interstitial if it's loaded.
if (interstitialAd.isReady()) {
interstitialAd.show();
} else {
Log.d(LOG_TAG, "Interstitial ad was not ready to be shown.");
}
}
}

/** Called when an ad is clicked and about to return to the application. */
@Override
public void onDismissScreen(Ad ad) {
Log.d(LOG_TAG, "onDismissScreen");
Toast.makeText(this, "onDismissScreen", Toast.LENGTH_SHORT).show();
}

/** Called when an ad was not received. */
@Override
public void onFailedToReceiveAd(Ad ad, AdRequest.ErrorCode error) {
String message = "onFailedToReceiveAd (" + error + ")";
Log.d(LOG_TAG, message);
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();

// Change the button text and disable the button.
if (ad == interstitialAd) {
showButton.setText("Failed to Receive Ad");
showButton.setEnabled(false);
}
}

/**
* Called when an ad is clicked and going to start a new Activity that will
* leave the application (e.g. breaking out to the Browser or Maps
* application).
*/
@Override
public void onLeaveApplication(Ad ad) {
Log.d(LOG_TAG, "onLeaveApplication");
Toast.makeText(this, "onLeaveApplication", Toast.LENGTH_SHORT).show();
}

/**
* Called when an Activity is created in front of the app (e.g. an
* interstitial is shown, or an ad is clicked and launches a new Activity).
*/
@Override
public void onPresentScreen(Ad ad) {
Log.d(LOG_TAG, "onPresentScreen");
Toast.makeText(this, "onPresentScreen", Toast.LENGTH_SHORT).show();
}

/** Called when an ad is received. */
@Override
public void onReceiveAd(Ad ad) {
Log.d(LOG_TAG, "onReceiveAd");
Toast.makeText(this, "onReceiveAd", Toast.LENGTH_SHORT).show();

// Change the button text and enable the button.
if (ad == interstitialAd) {
showButton.setText("Show Interstitial");
showButton.setEnabled(true);
}
}
}




Download
click to begin
1.2MB .zip

Telephony And SMS

package com.codefrux.smsapp;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class SMS extends Activity
{
Button btnSendSMS;
EditText txtPhoneNo;
EditText txtMessage;

    /** Called when the activity is first created. */
    @Override
CitySights NY
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);      
        btnSendSMS = (Button) findViewById(R.id.btnSendSMS);
        txtPhoneNo = (EditText) findViewById(R.id.txtPhoneNo);
        txtMessage = (EditText) findViewById(R.id.txtMessage);
       
     
               
        btnSendSMS.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v)
            {            
            String phoneNo = txtPhoneNo.getText().toString();
            String message = txtMessage.getText().toString();            
                if (phoneNo.length()>0 && message.length()>0)              
                    sendSMS(phoneNo, message);              
                else
                Toast.makeText(getBaseContext(),
                        "Please enter both phone number and message.",
                        Toast.LENGTH_SHORT).show();
            }
        });      
    }
   
CitySights NY
    //---sends a SMS message to another device---
    private void sendSMS(String phoneNumber, String message)
    {
    String SENT = "SMS_SENT";
    String DELIVERED = "SMS_DELIVERED";
   
        PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);
       
        PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,new Intent(DELIVERED), 0);
   
        //---when the SMS has been sent---
        registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode())
{
   case Activity.RESULT_OK:
   Toast.makeText(getBaseContext(), "SMS sent",Toast.LENGTH_SHORT).show();
   break;  
}
}
        }, new IntentFilter(SENT));      
       
        registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode())
{
   case Activity.RESULT_OK:
   Toast.makeText(getBaseContext(), "SMS Delivered Sucessfully",Toast.LENGTH_SHORT).show();
   break;  
}
}
        }, new IntentFilter(DELIVERED));    
   
        SmsManager sms = SmsManager.getDefault();
        sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
       
//    
     
    }  
   
   
}

Download
click to begin
1.2MB .zip

Android Sensor


package com.orientation;

import android.app.Activity;
import android.hardware.SensorListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class Orientation extends Activity implements SensorListener {
  private static final String TAG = "SensorDemo";
  private SensorManager sensorManager;
  private TextView outView;
  private int sensor = SensorManager.SENSOR_ORIENTATION;
  double[] values;

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    outView = (TextView) findViewById(R.id.output);
 


    // Real sensor manager
    sensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);


  }

  /** Register for the updates when Activity is in foreground */
  @Override
  protected void onResume() {
    super.onResume();
    Log.d(TAG, "onResume");
    sensorManager.registerListener(this, sensor);
  }

  /** Stop the updates when Activity is paused */
  @Override
  protected void onPause() {
    super.onPause();
    Log.d(TAG, "onPause");
    sensorManager.unregisterListener(this, sensor);
  }

  public void onAccuracyChanged(int sensor, int accuracy) {
    Log.d(TAG, String.format("onAccuracyChanged  sensor: %d   accuraccy: %d",
        sensor, accuracy));
  }

  public void onSensorChanged(int sensorReporting, float[] values) {
    if (sensorReporting != sensor)
      return;

CitySights NY
    float azimuth = Math.round(values[0]);
    float pitch = Math.round(values[1]);
    float roll = Math.round(values[2]);
 
    String out = String.format("Azimuth: %.2f  \n   Pitch: %.2f   \n   Roll: %.2f",azimuth, pitch, roll);
 
    Log.d(TAG, out);
 
    outView.setText(out);
  }
}
Download
click to begin
1.2MB .zip

Android Notification

Android Google Maps

Please refer pdf for explanation :-


package com.androidbook;

import android.os.Bundle;
import android.view.View;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

public class MapViewDemoActivity extends MapActivity
{
    private MapView mapView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.mapview);

        mapView = (MapView)findViewById(R.id.mapview);
    }

    public void myClickHandler(View target) {
        switch(target.getId()) {
        case R.id.zoomin:
            mapView.getController().zoomIn();
            break;
        case R.id.zoomout:
            mapView.getController().zoomOut();
            break;
        case R.id.sat:
            mapView.setSatellite(true);
            break;
        case R.id.street:
            mapView.setStreetView(true);
            break;
        case R.id.traffic:
            mapView.setTraffic(true);
            break;
        case R.id.normal:
            mapView.setSatellite(false);
            mapView.setStreetView(false);
            mapView.setTraffic(false);
            break;
        default:
        break;
        }

        // The following line should not be required but it is,
        // at least up til Froyo.
        mapView.postInvalidateDelayed(2000);
    }

    @Override
    protected boolean isLocationDisplayed() {
        return false;
    }

    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }
}
CitySights NY

Download
click to begin
1.2MB .zip

Android Layouts and Views

package com.android.layout;

import android.app.Activity;
import android.os.Bundle;

//You can set the orientation of the LinearLayout to LinearLayout.VERTICAL,
//or LinearLayout.HORIZONTAL. If you select VERTICAL, then all your components
//added to this container will be stacked on top of each other. If you pick HORIZONTAL,
//they will all be stacked beside each other.
// This weight determines how much empty space the component should take up in the final layout.
//Before adding a component to this container, you have to set its LinearLayout.LayoutParams.
//This specifies the height and width constraints you want to assign to your component.
//You can specify the “gravity” for each component that’s in the LinearLayout. This determines whether the component
//is left or right aligned, and top or bottom aligned, or a combination of these.

public class HelloLinearLayoutActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

Download
click to begin
1.2MB .zip

Saturday, 7 December 2013

Brief Android ?

How these Android tutorial work :- 1]Download Pdf and Working code [link given below] 2]Run code on your environment[eclipse or studio]
Hotels.com
3]Refer PDF for explanation By this approach you will condition your self to understand the code .
Download Me
click to begin
1.2MB .zip

Android , tips on programming

Hey Guys I am back with brand new spanking Android tutorials
How these Android tutorial work :-
1]Download Pdf and Working code [link given below]
2]Run code on your environment[eclipse or studio]
3]Refer PDF for explanation
  By this approach you will condition your self to understand code .
Programming is 40% knowledge and 60% experience
So spend atleast 4 hours coding in a day .
How?
To me Programming is all about problem solving
Read a lot of literature or watch movies like saw , cube [just saying]
I tried but didn't work ?
Don't be afraid to commit mistakes
try to approach a task in different ways
I have noticed developers in my company , when a program executes they jump out of joy and don't care if the code works on other condition .
As a good programmer you should always focus on designs , prototypes etc
Ill provide you further tips on how to be a good programmer later on my blogs.



 A lot of effort was invested for the Intro slide , download from link given
Download Me
click to begin
3.2MB