Messy methods and classes encountered during Android Development

Source: Internet
Author: User

1. componentname

This class is mainly used to obtain the activity name of the package name and forward it to this activity.


Ntent. setcomponent (componetname );
Startactivity (intent );


2. startactivities (intent [])
Startactivities (buildintentstoviewslists ());
We often use startactivity (intent), while startactivities (intent []) play the same role as startactivities,
It is nothing more than adding the jump target activity pointed to by the three intent [] to the current activity stack in sequence from the back to the front, if you use the "back" key after clicking the button,
The returned sequence is the same as that in intent [] From the back to the front.

3. Remove the title bar
Requestwindowfeature (window. feature_no_title); // remove the title bar.
// Cancel the status bar
This. getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen,
Windowmanager. layoutparams. flag_fullscreen );

4. Color textview directly with the color value
Color. parsecolor ("ffffff)
TV. settextcolor (color. RGB (255,255,255 ));
Settextcolor (0xff737373 );

5. threads
The interrupt () method can interrupt the thread that is being executed. If the thread is sleep () at this time, an error will be reported.
6. Press back to return to the desktop without exiting the program
Intent home = new intent (intent. action_main );
Home. setflags (intent. flag_activity_clear_top );
Home. addcategory (intent. category_home );
Startactivity (home );

7. install an APK on the SDK

  public void installApk(File file) {Uri uri = Uri.fromFile(file);Intent intent = new Intent(Intent.ACTION_VIEW);intent.setDataAndType(uri, "application/vnd.android.package-archive");startActivity(intent);}

8. display text of different colors in segments in textview text

Edittext2.settext (HTML. fromhtml ("<font color = # e61a6b> red code </font>" + "<I> <font color = # 1111ee> blue italic Code </font> </I>" + "<u> <I> <font color = # 1111ee> blue italic and bold underline Code </font> </I> </u> "));

Unfortunately, HTML classes do not support font size setting.

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.