Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.nitinranjan.callingapp;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends Activity {
EditText call_number;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
call_number = (EditText)findViewById(R.id.number_edit);
}
//************ this function is called when any button is prased in our activity****************
public void input(View view){
switch (view.getId()){
case R.id.text_0:
call_number.setText(call_number.getText().toString() + '0');
break;
case R.id.text_1:
call_number.setText(call_number.getText().toString()+'1');
break;
case R.id.text_2:
call_number.setText(call_number.getText().toString()+'2');
break;
case R.id.text_3:
call_number.setText(call_number.getText().toString()+'3');
break;
case R.id.text_4:
call_number.setText(call_number.getText().toString()+'4');
break;
case R.id.text_5:
call_number.setText(call_number.getText().toString()+'5');
break;
case R.id.text_6:
call_number.setText(call_number.getText().toString()+'6');
break;
case R.id.text_7:
call_number.setText(call_number.getText().toString()+'7');
break;
case R.id.text_8:
call_number.setText(call_number.getText().toString()+'8');
break;
case R.id.text_9:
call_number.setText(call_number.getText().toString()+'9');
break;
case R.id.text_cross:
call_number.setText(call_number.getText().toString()+"*");
break;
case R.id.text_backspace:
String s = call_number.getText().toString();
if(s.length()>0)
s = s.subSequence(0,s.length()-1).toString();
call_number.setText(s);
break;
case R.id.text_CALL:
String number = call_number.getText().toString();
Intent intent=new Intent(Intent.ACTION_CALL); //making intent for calling
intent.setData(Uri.parse("tel:"+number));
startActivity(intent);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment