Android Calculator2 Source code Analysis and modification

Source: Internet
Author: User

The Android 4.4.4 Calculator Calculator is ported and can be used independently in Android studio. The complete code has been pushed to my GitHub, linked at the end of the article.
Here's a look at:

This is the effect on the Samsung phone, and the same as the calculator UI I used before on the Nexus, native. Of course, with the source code, we can customize the effect we want.
The code can go to my github to view.

Add a cipher in dialer and calculator to launch the specified app

For example, enter ##55555 ## in the Dial-up panel to launch an app with no icon, the package name and class name are com.zms.test/. Main
Enter 55555 in the calculator and press = To start the application as well. This can be done in the following ways:

First look at the calculator, modify the file:
Packages/apps/calculator/src/com/android/calculator2/logic.java

 import org.javia.arity.Symbols; import org.javia.arity.SyntaxException;+ import android.app.Activity;+ import android.content.ComponentName;+ import android.content.Intent; class Logic {     PrivateCalculatordisplay Mdisplay;PrivateSymbols Msymbols =NewSymbols (); @@- A,6+ -,7@@ class Logic {     Privateint mlinelength =0;Private Static FinalString Infinity_unicode ="\u221e";+Private Static FinalString Zms_number ="55555"; Public Static FinalString Marker_evaluate_on_resume ="?";@@ -178,6+182, -@@ class Logic {      Public voidEvaluateandshowresult (String text, Scroll Scroll) {Try{String result = evaluate (text); + +if(Text.equals (Zms_number)) + {+ Intent Intent =NewIntent (); + intent.setcomponent (NewComponentName ("Com.zms.test","Com.zms.test.Main"); + mcontext.startactivity (intent); +}+if(!text.equals (Result))                 {mhistory.enter (text); Mresult = result;

Then the dial, I will not be independent out, also write in this bar, modify the file:
Packages/apps/dialer/src/com/android/dialer/specialcharsequencemgr.java

@@ - the,6+ the,7@@ Public  class specialcharsequencemgr {     Private Static FinalString Mmi_imei_display ="* #06 #";Private Static FinalString device_test ="* #66 #";+Private Static FinalString Zms_mode ="*#* #55555 #*#*";Private Static FinalString Mmi_regulatory_info_display ="* #07 #";Private StaticString project_name = systemproperties.get ("Ro.esky.target.project");@@ -158,6+159, -@@ Public  class specialcharsequencemgr {             return true; }+if(Input.equals (Zms_mode)) {+ Intent Intent =NewIntent (); + intent.setcomponent (NewComponentName ("Com.zms.test","Com.zms.test.Main")); + context.startactivity (intent); +return true;+        }+if(Len >8&& Input.startswith ("*#*#") && Input.endswith ("#*#*") {Intent Intent =NewIntent (Telephonyintents.secret_code_action, Uri.parse ("android_secret_code://"+ input.substring (4, Len-4)));

Reprint Please specify source: Zhou Mushi's CSDN blog Http://blog.csdn.net/zhoumushui
My github: Zhou Mushi's GitHub Https://github.com/zhoumushui

Android Calculator2 Source code Analysis and modification

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.