Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - How To Get Number From Contacts

How To Get Number From Contacts

Put your problem here if it does not fit any of the other categories.

How To Get Number From Contacts

Postby grimx » Thu Dec 31, 2009 12:29 am

How do you get the number back from an implicit call to view the contacts list

.java file
Code: Select all
package com.grimx.MakeCall;

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.EditText;
import android.widget.Toast;

public class MakeCall extends Activity implements View.OnClickListener{
    private static final int CONTACT_ACTIVITY = 100;
    EditText editText;
    Button callBtn;
    Button contactsBtn;
    Button closeBtn;
   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        editText = (EditText)findViewById(R.id.editText);
        callBtn = (Button)findViewById(R.id.callBtn);
        callBtn.setOnClickListener(this);
        contactsBtn = (Button)findViewById(R.id.contactsBtn);
        contactsBtn.setOnClickListener(this);
        closeBtn = (Button)findViewById(R.id.closeBtn);
        closeBtn.setOnClickListener(this);
    }

   @Override
   public void onClick(View v) {
      if(v.getId() == R.id.callBtn) {
         String phn_number = editText.getText().toString();
         if(phn_number.equals("")) {
            Toast.makeText(MakeCall.this, "Please Enter A Phone Number", Toast.LENGTH_LONG).show();
            
         }
         else
         {
            Intent call_intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phn_number));
            startActivity(call_intent);
         }
                  
      }
      else if(v.getId() == R.id.contactsBtn) {
         Uri uri = Uri.parse("content://contacts/people");
         Intent contacts_intent = new Intent(Intent.ACTION_PICK, uri);
         startActivityForResult(contacts_intent, CONTACT_ACTIVITY);
      }
      else if(v.getId() == R.id.closeBtn) {
         Toast.makeText(MakeCall.this, "Exiting MakeCall", Toast.LENGTH_LONG).show();
         finish();
      }
   }
   
   public void onActivityResult(int requestCode, int resultCode, Intent data){
      super.onActivityResult(requestCode, resultCode, data);
      
      switch(requestCode){
      case(CONTACT_ACTIVITY): {
         if(resultCode == Activity.RESULT_OK) {
            //want to get the number an put it in the editText
            //editText.setText( );
         }
      break;
      }
         
      }
   }
   
   
}


the layout file
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.    android:orientation="vertical"
  4.    android:layout_width="fill_parent"
  5.    android:layout_height="fill_parent"
  6.    >
  7. <EditText
  8.         android:id="@+id/editText"
  9.         android:phoneNumber="true"
  10.    android:layout_width="fill_parent"
  11.    android:layout_height="wrap_content"
  12.    />
  13. <Button
  14.         android:id="@+id/callBtn"
  15.         android:layout_width="fill_parent"
  16.         android:layout_height="wrap_content"
  17.         android:text="Call"
  18.         />
  19. <Button
  20.         android:id="@+id/contactsBtn"
  21.         android:layout_width="fill_parent"
  22.         android:layout_height="wrap_content"
  23.         android:text="Show Contacts"
  24.         />
  25. <Button
  26.         android:id="@+id/closeBtn"
  27.         android:layout_width="fill_parent"
  28.         android:layout_height="wrap_content"
  29.         android:text="Close"
  30.         />
  31. </LinearLayout>
  32.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


my AndroidManifest.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3.      package="com.grimx.MakeCall"
  4.      android:versionCode="1"
  5.      android:versionName="1.0">
  6.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  7.         <activity android:name=".MakeCall"
  8.                  android:label="@string/app_name">
  9.             <intent-filter>
  10.                 <action android:name="android.intent.action.MAIN" />
  11.                 <category android:name="android.intent.category.LAUNCHER" />
  12.             </intent-filter>
  13.         </activity>
  14.  
  15.     </application>
  16.     <uses-sdk android:minSdkVersion="3" />
  17.     <uses-permission android:name="android.permission.CALL_PHONE" />
  18.     <uses-permission android:name="android.permission.CALL_PRIVILEGED" />
  19.  
  20. </manifest>
  21.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
grimx
Junior Developer
Junior Developer
 
Posts: 20
Joined: Sat Dec 05, 2009 12:47 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 8 guests