Common Errors and skills in Google Android Development

Source: Internet
Author: User

1. Network unavailable: Permission denied (maybe missing Internet permission)

InAndroidAdded the allowed Network option in mainifest. XML (after the end tag> ):

<Uses-Permission Android: Name = "android. Permission. Internet"/>

2. Activity Class not found: Android. content. activitynotfoundexception: unable to find explicit activity class {XXXX}

Add the Activity Statement in androidmainifest. XML, for example:

<Activity Android: Name = ". xxxactivity">

</Activity>
 

3. Why can't I find the startsubactivity method?

Now, use the startactivityforresult method to replace the old startsubactivity method.

4. View in XML cannot be loaded, and a java. Lang. nullpointerexception exception is reported.

Forget to load the layout file of the activity:

Setcontentview (R. layout. Main );

5. unparsed aapt error (s )! Check the console for output

If you cannot find an error or cannot understand the error on the console, click Project ---------> clean ....

6. Differences between requestcode and resultcode

When startactivityforresult () and onactivityresult () are used, requestcode and resultcode are used respectively. Sometimes, it is very easy to confuse the two parameters.

The obfuscation between requestcode and resultcode is incorrect. Startactivityforresult, you can use onactivityresult () to distinguish the data returned by a sub-module. for Java, D, and even e sub-modules, it is better to separate different requestcodes for each partition. Setresut (INT resultcode, intent) resultcode if the B submodule may return several different results, you can use this parameter for identification and differentiation. There is also a special result_ OK value here, it is good to use it without special circumstances, the SDK has instructions, ah. Intent will not be explained. The onactivityresult () onactivityresult (INT requestcode, int resultcode, intent) returned to a will not be explained here. If you do not distinguish requestcode from resultcode, there will be no difference as long as other activities setresult reach a onactivityresult.

7. Files cannot be downloaded to the SD card.

Add <uses-Permission Android: Name = "android. Permission. write_external_storage"/> to the manifest file.

8. Center the control in the parent container:

Android: layout_gravity = "center_vertical"

 

Http://www.getcn.net/index.php? MoD = Skill & Action = detail & id = 43943

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.