Katana24
Katana24

Reputation: 39

Selecting & Calling numbers

I have a few numbers in an activity which I would like to be-able to make selectable, like a hyperlink. When the number is pressed it should call the number. I have checked the Android API but wasn't successful.

Anyone have any ideas?

Code for the button from the comment below is:

DialButton=(Button)findViewById( R.id.dialbutton );

DialButton.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View view)
            {
                if(number!=null){
                      try {
                        startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + number.getText())));
                      } catch (Exception e) {
                        e.printStackTrace();
                        }
                    }//if
                  }
        });

So what gives? Also in the "AndroidManifest.xml" file I specified the permissions like this:

  <uses-permission android:name="android.permission.CALL_PRIVILEGED" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".main"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>

Is this wrong? Is the permission in the wrong place?

Upvotes: 0

Views: 242

Answers (1)

Olegas
Olegas

Reputation: 10507

<TextView 
   android:text="+1........"
   android:autoLink="phone" />

http://developer.android.com/reference/android/widget/TextView.html#attr_android:autoLink

Also, don't forget to add a corresponding permission to manifest file

<uses-permission android:name="android.permission.CALL_PHONE" />

Upvotes: 1

Related Questions