Android Project Mobile Security Defender (01)

Source: Internet
Author: User

Directory
    • Project Structure diagram
    • Source
    • Run results
Project Structure diagram

Source Code Splashactivity.java
Package Com.coderdream.mobilesafe.activity;import Android.app.activity;import Android.content.pm.PackageInfo; Import Android.content.pm.packagemanager;import Android.os.bundle;import Android.view.window;import Android.view.windowmanager;import Android.widget.textview;import Com.coderdream.mobilesafe.r;public Class Splashactivity extends Activity {private TextView tv_splash_version; @Overridepublic void OnCreate (Bundle Savedinstancestate) {super.oncreate (savedinstancestate);//set to no title bar requestwindowfeature (Window.feature_no_title) ;//set to full-screen mode GetWindow (). SetFlags (Windowmanager.layoutparams.flag_fullscreen,windowmanager.layoutparams.flag_ fullscreen); Setcontentview (r.layout.activity_splash); tv_splash_version = (TextView) Findviewbyid (R.id.tv_splash_ version); Tv_splash_version.settext ("Release number:" + getversion ());}  /** * <pre> * Gets the version number of the current application. * The version number is in the corresponding manifest file in our apk (after extracting the APK directly, we can see the corresponding manifest file), * The version number is Android:versionname= "1.0" in the Manifest node * When an application is loaded into the phone, The APK is copied to the Data/app directory of the phone (that is, the system), * 6. So to get the version number, we need toTo get the system-related services, you can get the information in the APK * * </pre> * * @return */private String getversion () {//Get the System Package Manager. Has got the object-oriented wrapper of the apk packagemanager pm = This.getpackagemanager (); try {//parameter one: The current application's package name parameter two: Optional additional message, which we can't use here, can be defined as 0PackageInfo info = pm.getpackageinfo (getpackagename (), 0);//Returns the version number of the current application return info.versionname;} catch (Exception e) {//The exception that the package name does not find, theoretically, the exception cannot occur e.printstacktrace (); return "";}}

Androidmanifest.xml
<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http://schemas.android.com/apk/res/ Android "package=" Com.coderdream.mobilesafe "android:versioncode=" 1 "android:versionname=" 1.0 "> <uses-s DK android:minsdkversion= "8" android:targetsdkversion= "/>" <application android:allowback Up= "true" android:icon= "@drawable/ic_launcher" android:label= "@string/app_name" Android:theme= "@style            /apptheme "> <activity android:name=" com.coderdream.mobilesafe.activity.SplashActivity " Android:label= "@string/app_name" > <intent-filter> <action android:name= "android.in Tent.action.MAIN "/> <category android:name=" Android.intent.category.LAUNCHER "/> </ Intent-filter> </activity> </application></manifest>
Run results

Android Project Mobile Security Defender (01)

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.