Android Experience 3--Dialer

Source: Internet
Author: User

1. A little sentiment

These two days of programming every day a null pointer exception, can not find the activity of what the exception, in short, a variety of not compile the implementation of the Times wrong exception, and in the written apk application escalation error, I was puzzled, Java anyhow to mention a mistake, Android is always unknown, this makes me very depressed, Although Android also has a special console output to indicate the various results bar ... But the tip is always Yixieqianli, let the programmer at first glance, confused, the teacher's instructions finally realized through the mystery, here with you share. Don't panic when you see a big push error. The analysis thought is: First from the wrong first line look, generally find "fatal exception:main" (fatal accident), and then look at his next line: such as a dialer error: " Android.content.ActivityNotFoundException:no Actiivityfound to handle Intent{act=android,intent.action.all_appsdat =TEL:XXX-XXX-XXXX} "

This found the source of the error, look at his tip it is not difficult to find that this is an activity has not been found abnormal, return source code can find this line: intentintent =new Intent (Intent.action_all_apps , Uri.parse ("tel" +et.tostring ()); it's not hard to find the intent here. . Action_all_apps wrong code, dialer, of course, is intent.action_call, the most important is the most easily overlooked a problem is: "Tel:", remember that there is a colon behind the Tel, must not forget to add, I will keep reminding you that the activity has not been created. So the problem has been solved here.

To sum up, IT industry test is a careful and patient, most people look at the preparation of the time did not complain, there is no wrong to find the patience, when you have the wrong idea, and then calm down, carefully look at the Android console prompts the error, look back to the corresponding prompt line code, the problem is actually very good solution, The only thing that's hard to solve is your mindset.

2. Through these days of study, enumerate some Android errors:

Failed to find provider info forcom.google.settings (information not found for com.google.settings vendor)

Atdalvik.system.NativeStart.main (Native method) (native main methods)

Unable to get view server version Fromdevice emulator-5554 (Unable to obtain view servers versions from Device Emulator-5554)

Unable to gets view server protocolversion from Device emulator-5554 (unable to obtain View Servers protocol version from Device Emulator-5554)

No activity found to handle Intent (no active discovery of intent to deal with)

Unable to load the Windows list from device emulator-5554 (Unable to load window listing from Device Emulator-5554)

3. Let's write a simple dialer code below.

The following illustration is an effect chart:

packagecn.csdn.hr.activity;

importandroid.app.Activity;

Importandroid.content.Intent;

Importandroid.net.Uri;

Importandroid.os.Bundle;

importandroid.text.Editable;

Importandroid.view.View;

Importandroid.widget.Button;

Importandroid.widget.EditText;

Publicclass Callphoneactivity extends Activity {

/** called is firstcreated. */

@Override

public void OnCreate (bundlesavedinstancestate) {

Super.oncreate (savedinstancestate);

Set the view interface for display

Setcontentview (R.layout.main);

Get the appropriate component in the layout file

Button callphonebtn = (button) Findviewbyid (R.ID.CALLPHONEBTN);

Register Click events for buttons

Callphonebtn.setonclicklistener (Newview.onclicklistener () {

@Override

public void OnClick (View v) {

Get Input Box | Editable box object, dialing settings

EditText EditText = (edittext) Findviewbyid (R.id.editcallphone);

Get the phone number entered

Editable Editable =edittext.gettext ();

Set Dial Intent

Intent Intent = newintent (Intent.action_call,uri.parse ("Tel:" +editable.tostring ());

"Tel:" +editable.tostring () "This is a fixed format, dialing settings must be added" tel: "prefix;

Execution intent

StartActivity (Intent);

}

});

}

}

4. Layout

LinearLayout (linear layout), Absolutelayout (absolute layout), relativelayout (relative layout), tablelayout (table layout), Framelayout (frame layout)layouts are also divided into horizontal layouts (horizontal) and vertical layouts (vertical). 5. When you open the Android simulator, there is no signal, unplug the phone or send a text message, the prompt "not registered network" error message solution is as follows. l Scene One: Your computer is not connected to the Internet, but also not on the LAN. Solution: Right click on the Network Neighborhood, select "Properties", in the Internet Connection window right click "Local Connection", select "Properties", set TCP/IP properties as follows: IP Address: 192.168.1.100 Subnet Mask: 255.255.255.0 Default gateway: 192.168.1.100 Preferred DNS server: 192.168.1.100 L Scene Two: Your computer is not connected to the Internet, but on the LAN. Solution: Right click on the Network Neighborhood, select "Properties", in the Internet Connection window right click "Local Connection", select "Properties", set TCP/IP properties as follows: IP Address: Set to your local area network IP, such as: 192.168.1.100 Subnet Mask: Set to the mask of your local area network, such as: 255.255.255.0 Default gateway: Set to your local area network gateway, the general Gateway IP format is: *.*.*.1, such as: 192.168.1.1 Preferred DNS server: Set to your local area network router IP, the general router's IP format is: *.*.*.1, such as: 192.168.1.1 the last solution is to connect your computer to the Internet.

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.