Collection of issues encountered in Android development--occasional updates

Source: Internet
Author: User

The following questions are in the development of their own personal encounter, here to leave a backup, convenient next time to check.

1,java.lang.IllegalStateException ,cannot execute Task:the task has already been executed (a task C An is executed only once)

Illegal execution of the exception, roughly speaking, this task has been executed, can only perform a task

Workaround: Re -Execute the new task. Previously, the task class was initialized at the beginning, and then executed with the instance object execute where needed

2.java.lang.RuntimeException:Unable to start activity componentinfo{com.fozero.app.interfcalltest/ Com.fozero.app.interfcalltest.PhoneQueryActivity}: Java.lang.NullPointerException

Run-time exception, unable to open an active activity existence empty exception

Resolution: Found a long time to find that the target Activity in the initialization UI component ID was incorrectly written

3.Java.lang.IllegalStateException:ScrollView can host only one direct child

there can only be one direct child element inside the ScrollView

Workaround: Put all the components into the linearlayout layout, and then learnlayout layout is included in the ScrollView

4.android.view.viewrootimpl$calledfromwrongthreadexception:only The original thread that created a view Hierarchy can touch its views.

This exception occurs when a child thread updates the UI by using the handle class to update the UI

5.android.content.res.resources$notfoundexception:string resource ID #0xd7e

In the setText() method such as TextView , the parentheses are filled with an int type of thing? I have just met this problem, a good find, finally found. For numbers, many times as the ID of a resource , not just a number, such as setText()

the TextView . SetText () method has two:

1, setText (int resid) This method inside the parameter is r.string.*, that is, you have the string has been defined;

2, SetText (charsequence text) The parameter inside this method can be considered as a string type, this setText ("" +count) Way is equivalent to the count cast to a string type, or can be setText (string.valueof (count)) , both of which convert int Type into a String type.

6,

Appears "Unable to resolve target ' android-xx '", solution to enter your Android project with directory, find this file Project.Properties ( or default.properties), find target=android-xx This error occurs because your android Environment does not correspond to this, so you only need to change the Android version here to the one configured on your machine. Android version can be, for example target=android-15

7.Unable to add window – token null is not a for a application

The error that occurs when using the alertdialog dialog box in activity , where context uses the the context of application

new Alertdialog.builder (mcontext) Although the parameter here is alertdialog.builder (context context) getapplicationcontext () get the context, activity, because there is only one activity  

Workaround: Use the parameters in the new Alertdialog.builder (context context) with activity.this( Activity is the name of your activity to populate it to create a Dialog correctly .

8.android.util.AndroidRuntimeException:Calling startactivity () from outside of an Activity context req Uires the Flag_activity_new_task FLAG. is this really what do you want?

When calling context.startactivity (Intent) , the error , the workaround:

Add intent.addflags (flag_activity_new_task) in front or use activity.startactivity (Intent)

Collection of issues encountered in Android development--occasional updates

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.