Android Open Source - DialQuick_Android Setup Phone Activity






From Project

Back to project page DialQuick_Android.

License

The source code is released under:

GNU General Public License

If you think the Android project DialQuick_Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.blogspot.techzealous.ui;
//from   www.j  ava 2  s  .c om
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.blogspot.techzealous.dialquick.DialQuickConstants;
import com.blogspot.techzealous.dialquick.R;

public class SetupPhoneActivity extends Activity {

  private Button buttonOk;
  private Button buttonContacts;
  private EditText editTextPhone;
  private TextView textViewCurrentNumber;
  private SharedPreferences prefs;
  private int codeForContacts = 2;
  
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.setupnumber);
    
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    buttonOk = (Button) findViewById(R.id.buttonSetupNumberOk);
    buttonContacts = (Button) findViewById(R.id.buttonContacts);
    editTextPhone = (EditText) findViewById(R.id.editTextPhoneNumber);
    textViewCurrentNumber = (TextView) findViewById(R.id.textViewCurrentNumber);
    
    textViewCurrentNumber.setText(prefs.getString(DialQuickConstants.PREF_TEL_NUMBER, getResources().getString(R.string.notset)));
    
    buttonContacts.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        Intent i = new Intent(SetupPhoneActivity.this, ContactsActivity.class);
        startActivityForResult(i, codeForContacts);
      }
    });
    
    buttonOk.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {
        prefs.edit().putString(DialQuickConstants.PREF_TEL_NUMBER, editTextPhone.getText().toString()).commit();
        textViewCurrentNumber.setText(prefs.getString(DialQuickConstants.PREF_TEL_NUMBER, getResources().getString(R.string.notset)));
      }
    });
  }
  
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == codeForContacts && resultCode == Activity.RESULT_OK) {
      editTextPhone.setText(data.getStringExtra(DialQuickConstants.PREF_TEL_NUMBER));
    }
  }
}




Java Source Code List

com.blogspot.techzealous.dialquick.DialQuickConstants.java
com.blogspot.techzealous.ui.ContactsActivity.java
com.blogspot.techzealous.ui.DQEula.java
com.blogspot.techzealous.ui.DQWellcome.java
com.blogspot.techzealous.ui.DialCallDialogActivity.java
com.blogspot.techzealous.ui.MainActivity.java
com.blogspot.techzealous.ui.SetupPhoneActivity.java