Android Development Tutorials Get the application name using the current API _android

Source: Internet
Author: User

For example, to get the name of the application that opens the camera, just add the following code to the open () method in Frameworks/base/core/android/hardware/camera.java.

Copy Code code as follows:

Application application = Activitythread.currentapplication ();
if (application!= null) {
String PackageName = Application.getpackagename ();
try {
ApplicationInfo packageinfo= Application.getpackagemanager (). Getapplicationinfo (packagename,packagemanager.get_ Meta_data);
String appName = Application.getpackagemanager (). Getapplicationlabel (PackageInfo). toString ();
catch (Exception e) {
E.printstacktrack ();
}

Applicationlabel is the application name, which is defined in Androidmanifest.xml.

The following is the application of the Android 2.3Camera.



Its application name is camera.

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.