project blog responsive ads

Free download management system project documentation with JAVA, PHP AND ASP.NET source code. In all project report you will get introduction and objective of the project, system analysis, feasibility study, project planning, DFD diagram, system design, database design, complete project coding, and ER diagram of the project. These project reports and synopsis are useful for BCA, MCA BSC CS, MSC IT B.TECH, M.TECH and BE computer science last year students IGNOU, SMU university final year projects

Sponsored Links

Thursday, December 12, 2013

SYSTEM CODING & IMPLEMENTATION




1.    SYSTEM CODING & IMPLEMENTATION

5.1 Coding :
package com.call;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
public class calllogs extends Activity {
    SQLiteDatabase mydb=null;
      String TableName="AndroidLogCallHistory";
      Cursor c1,c2,c3;
      String Name="",Phone=null,Phone1=null;
      String duration=null;
      String type=null;
      int count;View row;
      int i=0;
      ArrayList l1=new ArrayList();
      ArrayList l2=new ArrayList();
      ArrayList ctype=new ArrayList();
      ArrayList nooftimes=new ArrayList();
     
          public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contactsresult);
        try
                  {
                              mydb=openOrCreateDatabase("DatabaseName5", MODE_PRIVATE,null);
                              mydb.execSQL("CREATE TABLE IF NOT EXISTS "
                                                      +TableName
                                                      +" (CallName varchar,CallNumber varchar,CallDuration integer,CallType varchar,Time long);");
                               c1=mydb.rawQuery("SELECT * FROM "+TableName,null);
                              boolean b = c1.moveToFirst();
                              if(!b)
                  {
                             
                  Cursor c=getContentResolver().query
        (android.provider.CallLog.Calls.CONTENT_URI,
                              null, null,null,
                              android.provider.CallLog.Calls.DATE + " DESC ");
        startManagingCursor(c);
        int name=c.getColumnIndex(android.provider.CallLog.Calls.CACHED_NAME);
        int number=c.getColumnIndex(android.provider.CallLog.Calls.NUMBER);
        int datecolumn=c.getColumnIndex(android.provider.CallLog.Calls.DATE);
        int typeofcall=c.getColumnIndex(android.provider.CallLog.Calls.TYPE);
        int time=c.getColumnIndex(android.provider.CallLog.Calls.DURATION);
        if(c.moveToFirst())
        {
                  do
                  {           String callname=c.getString(name);
                             
                              String callno=c.getString(number);
                              long created = c.getLong(datecolumn);
                             
                              int duration=c.getInt(time);
                              int type=c.getInt(typeofcall);
                              String calltype=null;
                              switch(type)
                              {
                              case android.provider.CallLog.Calls.MISSED_TYPE:
                                          calltype="missed call";
                              break;
                              case android.provider.CallLog.Calls.INCOMING_TYPE:
                                          calltype="incoming call";
                              break;
                              case android.provider.CallLog.Calls.OUTGOING_TYPE:
                                          calltype="outgoing call";
                              break;
                              }
                              mydb.execSQL("INSERT INTO "+TableName+"(CallName,CallNumber,CallDuration,CallType,Time)"+"VALUES('"+callname+"','"+callno+"',"+duration+",'"+calltype+"',"+created+");");
                              }while(c.moveToNext());
        }         }
                              else
        {
                                          Cursor c3=mydb.rawQuery("SELECT MAX(Time) FROM "+TableName, null);
                                         
                             
                                          if(c3.moveToFirst())
                                          {
                                                      long time2=c3.getLong(0);
                                                      c3.close();
                                                      //System.out.println("max time is"+time2);
                                                      Cursor c=getContentResolver().query
                                      (android.provider.CallLog.Calls.CONTENT_URI,
                                                      null, null,null,
                                                      android.provider.CallLog.Calls.DATE +" DESC ");
                                      startManagingCursor(c);
                                      int name=c.getColumnIndex(android.provider.CallLog.Calls.CACHED_NAME);
                                      int number=c.getColumnIndex(android.provider.CallLog.Calls.NUMBER);
                                      int datecolumn=c.getColumnIndex(android.provider.CallLog.Calls.DATE);
                                      int typeofcall=c.getColumnIndex(android.provider.CallLog.Calls.TYPE);
                                      int time=c.getColumnIndex(android.provider.CallLog.Calls.DURATION);
                                      if(c.moveToFirst())
                                      {
                                          do
                                          {          
                                                      long created2 = c.getLong(datecolumn);
                                                      if(created2>time2){
                                                                  String callname=c.getString(name);
                                                                 
                                                                  String callno=c.getString(number);
                                                                  //System.out.println("n0 is "+callno);
                                                                  long created = c.getLong(datecolumn);
                                                      //          System.out.println("value is "+created);
                                                                  int duration=c.getInt(time);
                                                                  int type=c.getInt(typeofcall);
                                                                  String calltype=null;
                                                                  switch(type)
                                                                  {
                                                                  case android.provider.CallLog.Calls.MISSED_TYPE:
                                                                              calltype="missed call";
                                                                  break;
                                                                  case android.provider.CallLog.Calls.INCOMING_TYPE:
                                                                              calltype="incoming call";
                                                                  break;
                                                                  case android.provider.CallLog.Calls.OUTGOING_TYPE:
                                                                              calltype="outgoing call";
                                                                  break;
                                                                  }
                                                                  mydb.execSQL("INSERT INTO "+TableName+"(CallName,CallNumber,CallDuration,CallType,Time)"+"VALUES('"+callname+"','"+callno+"',"+duration+",'"+calltype+"',"+created+");");
                                                                 
                                                                 
                                                      }
                                                      else
                                                      {
                                                                 
                                                                  break;
                                                      }
                                                      }while(c.moveToNext());
                                      }  
                                                     
                                          }
                 
        }
       
      c2=mydb.rawQuery("SELECT CallNumber,CallType,MAX(Time),COUNT(CallNumber),CallName FROM "+TableName+" GROUP BY CallNumber,CallType ORDER BY MAX(Time) DESC", null);
        if(c2.moveToFirst())
        {
                  do{
                 
                  long created = c2.getLong(2);
                  Date date = new Date(created);
                  String date2[]=date.toString().split(" ");
                  String i1=Integer.toString(date.getDate());
                  String month=date2[1];
                  String calldate=i1+" "+month;
                  String dateString = DateFormat.getDateTimeInstance().format(date);
                  String[] dat=dateString.split(" ");
                  String dat2=dat[3];
                  String[] tim=dat2.split(":");
                  String calltime="";
                  if(dat.length==5)
                  {
                              calltime=tim[0]+": "+tim[1]+" "+dat[4];   
                  }else
                  {
                              if(Integer.parseInt(tim[0])>=12)
                              {
                                          if(Integer.parseInt(tim[0])==12)
                                          {
                                                      calltime=Integer.parseInt(tim[0])+": "+tim[1]+" "+"PM";
                                          }else
                                          {
                                         
                                          calltime=Integer.parseInt(tim[0])-12+": "+tim[1]+" "+"PM";
                                          }
                              }else
                              {
                                          calltime=tim[0]+": "+tim[1]+" "+"AM";
                              }
                             
                             
                  }
                  String name=c2.getString(4);
                  String no=c2.getString(0)+" ("+c2.getString(3)+")";
                  ctype.add(c2.getString(1));
                  nooftimes.add(c2.getString(3));
                  l2.add(c2.getString(0));
                  if(name.equals("null"))
                  {
                              l1.add(no+"\n"+calldate+"    "+calltime);
                  }
                  else
                  {
                              l1.add(c2.getString(4)+" ("+c2.getString(3)+")"+"  \n"+calldate+"    "+calltime);
                  }
        }while(c2.moveToNext());
                  ListView myList = (ListView)findViewById(R.id.myList);
                  myList.setAdapter(new MyCustomAdapter());
                  myList.setCacheColorHint(0);
                  myList.setOnItemClickListener(new OnItemClickListener()
                  {

                                         
                                          public void onItemClick(AdapterView arg0, View arg1,
                                                                  int arg2, long arg3) {
                                                      int s=Integer.parseInt(arg0.getItemAtPosition(arg2).toString());
                                                      String s1=l2.get(s);
                                                     
                                                      Intent it=new Intent(calllogs.this,listofcalls.class);
                                                      it.putExtra("no", s1);
                                                      it.putExtra("nooftimes", nooftimes.get(arg2));
                                                      it.putExtra("type",ctype.get(s));
                                                      startActivity(it);
                                                     
                                          }
                             
                  });
        }else
        {
                  TextView tv=new TextView(this);
                  tv.setText("No Call Logs Found");
                  tv.setTextSize(20);
        }
                  }
        catch(Exception e)
        {
                  e.printStackTrace();
        }
        finally{
                 
                  if (mydb != null)
                      mydb.close();
        }
       
       
       
    }
         
                 
class MyCustomAdapter extends BaseAdapter {
                 
                  public int getCount() {
                              return l1.size();
                             
                  }

                  public Object getItem(int position) {
            return position;
      }

      public long getItemId(int position) {
            return position;
      }


                  public View getView(int position, View convertView, ViewGroup parent) {
                              LayoutInflater inflater = getLayoutInflater();
                             
                              if(ctype.get(position).equals("missed call"))
                              {
                                          row = inflater.inflate(R.layout.missedcall, parent, false);
                                          TextView textLabel = (TextView) row.findViewById(R.id.text);
                                         
                                          textLabel.setText(l1.get(position));
                                         
                              }
                              else if(ctype.get(position).equals("outgoing call"))
                              {
                                          row = inflater.inflate(R.layout.outgoing, parent, false);
                                          TextView textLabel = (TextView) row.findViewById(R.id.text);
                                         
                                          textLabel.setText(l1.get(position));
                              }
                              else if(ctype.get(position).equals("incoming call"))
                              {
                                          row = inflater.inflate(R.layout.incoming, parent, false);
                                          TextView textLabel = (TextView) row.findViewById(R.id.text);
                                         
                                          textLabel.setText(l1.get(position));
                              }

                              return (row);
                  }
      }

}



package com.call;

import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

public class IncomingCallActivity extends Activity{
      SQLiteDatabase mydb=null;
      String TableName="AndroidLogCallHistory";
      int i=0;int count;View row;
      Cursor c2;
      ArrayList l1=new ArrayList();
      ArrayList l2=new ArrayList();
      ArrayList ctype=new ArrayList();
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contactsresult);
        try
                  {
                              mydb=openOrCreateDatabase("DatabaseName5", MODE_PRIVATE,null);
                              String call="incoming call";
                              c2=mydb.rawQuery("SELECT CallNumber,CallType,MAX(Time),COUNT(CallNumber),CallName FROM "+TableName+" WHERE CallType='"+call+"' GROUP BY CallNumber,CallType ORDER BY MAX(Time) DESC " , null);
              if(c2.moveToFirst())
              {
                  do{
                  long created = c2.getLong(2);
                  Date date = new Date(created);
                  String date2[]=date.toString().split(" ");
                  String i1=Integer.toString(date.getDate());
                              String month=date2[1];
                              String calldate=i1+" "+month;
                              String dateString = DateFormat.getDateTimeInstance().format(date);
                              String[] dat=dateString.split(" ");
                              String dat2=dat[3];
                              String[] tim=dat2.split(":");
                              String calltime="";
                              if(dat.length==5)
                              {
                                          calltime=tim[0]+": "+tim[1]+" "+dat[4];   
                              }else
                              {
                                          if(Integer.parseInt(tim[0])>=12)
                                          {
                                                      if(Integer.parseInt(tim[0])==12)
                                                      {
                                                                  calltime=Integer.parseInt(tim[0])+": "+tim[1]+" "+"PM";
                                                      }else
                                                      {
                                                     
                                                      calltime=Integer.parseInt(tim[0])-12+": "+tim[1]+" "+"PM";
                                                      }
                                          }else
                                          {
                                                      calltime=tim[0]+": "+tim[1]+" "+"AM";
                                          }
                                         
                                         
                              }
                  String name=c2.getString(4);
                  String no=c2.getString(0)+" ("+c2.getString(3)+")";
                  ctype.add(c2.getString(1));
                  l2.add(c2.getString(0));
                  if(name.equals("null"))
                  {
                              l1.add(no+"\n"+calldate+"    "+calltime);
                  }
                  else
                  {
                              l1.add(c2.getString(4)+" ("+c2.getString(3)+")"+"  \n"+calldate+"    "+calltime);
                  }
              }while(c2.moveToNext());
                 
                              ListView myList = (ListView)findViewById(R.id.myList);
                              myList.setAdapter(new MyCustomAdapter());
                              myList.setCacheColorHint(0);
                              myList.setOnItemClickListener(new OnItemClickListener()
                              {

                                                     
                                                      public void onItemClick(AdapterView arg0, View arg1,
                                                                              int arg2, long arg3) {
                                                                  String s1=l2.get(arg2);
                                                                  Intent it=new Intent(IncomingCallActivity.this,listofcalls.class);
                                                                  it.putExtra("no", s1);
                                                                  it.putExtra("type",ctype.get(arg2));
                                                                  startActivity(it);
                                                      }
                              });
                             
              }
             
          }catch(Exception e)
          {
                  e.printStackTrace();
          }finally{
                  //c2.close();
                  if (mydb != null)
                      mydb.close();
        }
    }
      class MyCustomAdapter extends BaseAdapter {
                             
                              public int getCount() {
                                          return l1.size();
                                         
                              }

                              public String getItem(int position) {
                                          // TODO Auto-generated method stub
                                          return null;
                              }

                              public long getItemId(int position) {
                                          // TODO Auto-generated method stub
                                          return position;
                              }

                              public View getView(int position, View convertView, ViewGroup parent) {
                                          LayoutInflater inflater = getLayoutInflater();
                                                                 
                               if(ctype.get(position).equals("incoming call"))
                                          {
                                                      row = inflater.inflate(R.layout.incoming, parent, false);
                                                      TextView textLabel = (TextView) row.findViewById(R.id.text);
                                                     
                                                      textLabel.setText(l1.get(position));
                                          }

                                          return (row);
                              }
                  }

       
    }

package com.call;

import java.util.List;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

public class View_PieChart extends View
{
public static final int WAIT = 0;
public static final int IS_READY_TO_DRAW = 1;
public static final int IS_DRAW = 2;
private static final float START_INC = 30;
private Paint mBagpaints = new Paint();
private Paint mLinePaints = new Paint();

private int mWidth;
private int mHeight;
private int mGapTop;
private int mGapBottm;
private int mBgcolor;
private int mGapleft;
private int mGapright;
private int mState = WAIT;
private float mStart;
private float mSweep;
private int mMaxConnection;
private List mdataArray;

public View_PieChart(Context context) {
super(context);
Log.w(" single cons ", " single cons");
}

public View_PieChart(Context context, AttributeSet attr) {
super(context, attr);
Log.w(" double cons ", " double cons");
}

@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mState != IS_READY_TO_DRAW) {
return;
}
canvas.drawColor(mBgcolor);
mBagpaints.setAntiAlias(true);
mBagpaints.setStyle(Paint.Style.FILL);
mBagpaints.setColor(0x88FF0000);
mBagpaints.setStrokeWidth(0.0f);
mLinePaints.setAntiAlias(true);
mLinePaints.setColor(0xff000000);
mLinePaints.setStrokeWidth(3.0f);
mLinePaints.setStyle(Paint.Style.STROKE);
RectF mOvals = new RectF(mGapleft, mGapTop, mWidth - mGapright, mHeight
- mGapBottm);
mStart = START_INC;
PieDetailsItem item;
for (int i = 0; i < mdataArray.size(); i++) {
item = (PieDetailsItem) mdataArray.get(i);
mBagpaints.setColor(item.color);
mSweep = (float) 360* ((float) item.count / (float) mMaxConnection);
canvas.drawArc(mOvals, mStart, mSweep, true, mBagpaints);
canvas.drawArc(mOvals, mStart, mSweep, true, mLinePaints);
mStart = mStart + mSweep;
}

mState = IS_DRAW;
}

public void setGeometry(int width, int height, int gapleft, int gapright,
int gaptop, int gapbottom, int overlayid) {

mWidth = width;
mHeight = height;
mGapleft = gapleft;
mGapright = gapright;
mGapBottm = gapbottom;
mGapTop = gaptop;

}

public void setSkinparams(int bgcolor) {
Log.w(" Set bg color  : ", bgcolor + "");
mBgcolor = bgcolor;
}

public void setData(List data, int maxconnection) {
mdataArray = data;
mMaxConnection = maxconnection;
Log.w(" Max Connection  ", maxconnection + " " + "  Adataarray :"
+ data.toString());
mState = IS_READY_TO_DRAW;
}

public void setState(int state) {
mState = state;
}

public int getColorValues(int index) {
if (mdataArray == null) {
return 0;
}

else if (index < 0)
return ((PieDetailsItem) mdataArray.get(0)).color;
else if (index > mdataArray.size())
return ((PieDetailsItem) mdataArray.get(mdataArray.size() - 1)).color;
else
return ((PieDetailsItem) mdataArray.get(mdataArray.size() - 1)).color;

}

public void setData(int itemCount, int maxCount) {
      // TODO Auto-generated method stub
     
}

}

package com.call;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

public class Network extends Activity{
      String s2=null;
     
      public void onCreate(Bundle b)
      {
                  super.onCreate(b);
                  setContentView(R.layout.network);
                  TextView tv=(TextView)findViewById(R.id.TextView01);
                  Bundle extras=getIntent().getExtras();
                 
                  s2=extras.getString("phone");
                 
                 
      
                  try {
                              InputStream is =getResources().openRawResource(R.raw.indiamobilesdata);
                              BufferedReader br = new BufferedReader(new InputStreamReader(is));
              String s;
              int linecount=0;
              String line;
              int i2=0;
              while ((s=br.readLine())!=null)
                                                        {
                                                        linecount++;
                                                        int indexfound=s.indexOf(s2);
                                                        if(indexfound>-1)
                                                                                            {
                                                                                                      i2=i2+1;
                                                                                                       line=s;
                                                                                                        String s5[]=line.split("=");
                                                                                                        String s10[]=s5[1].split("~");
                                                                                                        tv.append("Mobile Series:"+s2+"\n");
                                                                                                        for(int i=1;i
                                                                                                        {
                                                                                                                    
                                                                                                                    
                                                                                                                    tv.append(s10[i]+"\n");
                                                                                                                    
                                                                                                                    
                                                                                                                    
                                                                                                        }
                                                                                                        String s7[]=s10[3].split(":");
                                                                                                        String s6[]=s7[1].split(". ");
                                                                                                       
                                                                                                        if(s6[0].equals(" Airtel"))
                                                                                                        {
                                                                                                                   
                                                                                                                   ImageView image = (ImageView) findViewById(R.id.ImageView01);
                                                                                                  Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.airtel);
                                                                                                  image.setImageBitmap(bMap);
                                                                                                        }
                                                                                                       if(s6[0].equals(" Uninor"))
                                                                                                        {
                                                                                                                 
                                                                                                                  ImageView image = (ImageView) findViewById(R.id.ImageView01);
                                                                                                  Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.uninor);
                                                                                                  image.setImageBitmap(bMap);
                                                                                                        }
                                                                                                      if(s6[0].equals(" Vodafone"))
                                                                                                        {
                                                                                                                 
                                                                                                                  ImageView image = (ImageView) findViewById(R.id.ImageView01);
                                                                                                  Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.vodafone);
                                                                                                  image.setImageBitmap(bMap);
                                                                                                        }
                                                                                                        
                                                                                            }
                                                                                           
                                                        }
              if (i2==0)
                                {
                                            tv.setText("Sorry Not Found !");
                                }

              is.close();
             
                  } catch (Exception e) {
                              // TODO Auto-generated catch block
                              e.printStackTrace();
                  }
       
      }

}


No comments:

G+

Pages