The simplest and fastest dialing tool for Android development (including the source code)

Source: Internet
Author: User

After learning for a week, I finally learned basic controls such as textview, editview, And button, and a little bit of layout. Then, Jia Ge (my master) asked me to write a phone call, it's amazing, but after a piece of his code, I think it's really easy ~~~ The following describes the specific operations:

First, let's take a look at my achievements:

1. Control Layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:background="@drawable/bg"    tools:context=".MainActivity" > <TextView        android:id="@+id/txv"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="@string/tishi"        android:textColor="#D2691E"        android:textSize="20dp" />    <LinearLayout        android:id="@+id/linOut1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@id/txv"        android:orientation="horizontal" >        <Button            android:id="@+id/me"            android:layout_width="60dp"            android:layout_height="60dp"            android:layout_marginLeft="10dp"            android:layout_marginRight="20dp"            android:layout_marginTop="20dp"            android:layout_weight="1"            android:background="@drawable/niub" /></LinearLayout><LinearLayout        android:id="@+id/linOut_txt1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@id/linOut1"        android:orientation="horizontal" >        <TextView            android:id="@+id/txv1"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginLeft="20dp"            android:layout_marginRight="10dp"            android:layout_weight="1"            android:text="@string/txv1" /></LinearLayout>

2. Code implementation:

package com.example.phone;import android.net.Uri;import android.os.Bundle;import android.app.Activity;import android.content.Intent;import android.view.Menu;import android.view.MenuItem;import android.view.View;import android.widget.Button;import android.widget.Toast;public class MainActivity extends Activity {private Button  niu;protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);onclick();               niu.setOnClickListener(new BtnOnlick());    }    private void onclick() {        niu = (Button) findViewById(R.id.niu);    }    private class BtnOnlick implements View.OnClickListener {public void onClick(View v) {switch (v.getId()) {                        case R.id.niu:getIntent("##########");break;                        default:break;                    }               }    }    private void getIntent(String str) {Intent i_ling = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + str));startActivity(i_ling);}}                                                

  

Only one button and textview are used here. You can add them by yourself ~~~

3. Set permissions

Open androidmanifest. xml ----- and add the following code on the application Tag: <uses-Permission Android: Name = "android. Permission. call_phone"/>

4. Package (some of them need to be filled in as needed)

Right-click Project ----- export ----- andriod ----- export... ----- next --- next -----

5. Install and run it on your mobile phone. If you want to further study and exchange with us, you can add my new andriod group: 26040687. You are welcome to join us in learning and exchange ~~~~ Hahahaha

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.