Mobile Defender 13_ Screen Adapter _ exception Handling _ Profit Mode _ confuse encryption

Source: Internet
Author: User

Today is the last day of mobile defender

  

1, simple screen adaptation :

The ① uses linear , relative , frame layouts , which are three common layouts that can be implemented almost completely on all devices , using more DP,SP, do not use pixels , Dp,sp will automatically adapt to the screen

② Floating Form Displays the distance problem : the distance it shows is pixels , so the display distance does not fit the screen .

The units received in the code are generally pixels .

Workaround : Convert the input number into a dp Unit .

Get the pixel density * pixel to get dp data , based on the screen to achieve the pixel effect

Convert to DP data via tool class Desityutils

2, exception handling for the application :

2.1

Alpha version : Small range of internal tests , Bugs will be more , unstable

Beta version : more stable . you can consider publishing to the market.

Stable version , official version : basically no BUG

2.2

The application pops up the dialog box and stops running .

Rewrite the dialog box to get an exception to the file before the dialog pops up

① Create a class : Application class , inheriting application

Configure the manifest file application interface , Select the name tag , Configure this inheritance class to

②onCreate ()//The first method that executes before the application is created , is appropriate for the application initialization operation .

override the system's exception handler .

Thread.CurrentThread (). Getdefaultuncaughtexceptionhandler ()// Gets the exception handler for the current default uncaught exception , POPs up a dialog box with an abnormal stop

Thread.CurrentThread (). Setuncaughtexceptionhandler (Uncaughtexceptionhandlerhandler);

③ implement this exception handler, overriding the method to catch the exception message

But the virtual machine will still hang up, This is no way , but you can execute a few lines of code , The exception is written in the log

Then kill the current process ( or it will remain stuck on the interface ) early to die , the memory is sufficient to restart the case .

Android.os.Process.KillProcess (Android.os.Process.myPid ());// can only kill their own pid Process

Information processing for ④ application exceptions

Parameters in the Override method Throwable ex, Save the wrong information

Ex.printstacktrace (PS);// Write exception information to the print output stream

PrintWriter pw = new PrintWriter ( string output stream );// write the information into the string input stream

StringWriter SW = new StringWriter (); Sw.tostring ()// can get string

You can write the error message that this SW represents to the file.

⑤ only the wrong information is not enough

Also required : time System.currenttimemillis () to generate the error ;

Mobile phone operating System Information Build, using reflection to get , Getdeclaredfields ();// get field

traverse each field , Field.getname (); // field name

Field.get ( object , static can be null) // field represents the value

Friends League : Developer Service Platform , There is an exception to capture the JAR package more professional

3, Android's profit model

3.1 paid software ( typically less , go desktop with custom theme )

Value-Added Services ( appearing in general games )

Free apps to make money with AD traffic

Advertising platform : Baidu Mobile Alliance , there are meters and so on

Get the JAR Package to the ad platform and view the Help documentation for the platform release . It's a very detailed introduction.

4, encryption obfuscation of the application

In the project.properties file , open The config content config = ${sdk}xx Path

this file under the Sdk proguard-android.txt

Copy this file to the project and modify The filename specified by CONFIG.

Then export the apk ( digitally signed XXXX) so that the generated apk is encrypted and obfuscated.

Principle : when the apk file is generated , the class name and method name are dynamically modified ( the system does not look at the name anyway , The name is just for programmers to easily write. )

Mobile Defender 13_ Screen Adapter _ exception Handling _ Profit Mode _ confuse encryption

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.