"First line of Android" Reading notes: Find the activity that corresponds to the current interface

Source: Internet
Author: User

In Android development, find the activity that corresponds to the current interface, with the following steps:

  1. Create a new baseactivity to inherit from activity, and then rewrite the OnCreate () method in Baseactivity, using the GetClass (). Getsimplename () to get the class name of the current instance and print it through log. The code is as follows:
     Public class extends Activity {    protectedvoid  onCreate (Bundle savedinstancestate) {          Super. OnCreate (savedinstancestate);        LOG.D ("Baseactivity", GetClass (). Getsimplename ());}    }
  2. Change all activity in the project to inherit from Baseactivity, so that when the program enters any interface during the run (that is, when the OnCreate () method is executed), the current activity name is printed in Logcat. This allows us to know the relationship between the interface and the activity.

"First line of Android" Reading notes: Find the activity that corresponds to the current interface

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.