package com.example.listviewcustom05;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.view.View.OnClickListener;

public class Infos_Db extends Activity
{
	
	private DbAdapter handler;
	Button b1;
	
	public void onCreate(Bundle savedInstanceState) 
	{
		
			super.onCreate(savedInstanceState);
			setContentView(R.layout.infos_db);

			handler = new DbAdapter(getApplicationContext());
		
			
			handler.open();
			
			int cnt = handler.getContactsCount();
			
			String msg = "Nb de contacts dans la database: " + String.valueOf(cnt);
			
			
			TextView nb_record = (TextView) findViewById(R.id.textView5);
			nb_record.setText(msg );
			
			b1=(Button)findViewById(R.id.button1);
		   
		    
		    
			// add button listener
			b1.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0)
				{

					Intent callIntent = new Intent(Intent.ACTION_CALL);
					callIntent.setData(Uri.parse("tel:0377778888"));
					startActivity(callIntent);

				}

			});
			
			
	}

	private void call() {
	      
	      
	      Intent callIntent = new Intent(Intent.ACTION_CALL);
	      callIntent.setData(Uri.parse("tel:0377778888"));
	      startActivity(callIntent);
	      /*
	      Intent in=new Intent(Intent.ACTION_CALL,Uri.parse("0000000000"));
	      
	      try{
	         startActivity(in);
	      }
	      
	      catch (android.content.ActivityNotFoundException ex){
	         Toast.makeText(getApplicationContext(),"yourActivity is not founded",Toast.LENGTH_SHORT).show();
	      }*/
	   }
	   
}