如何检索来自Android的计算器值 [英] How retrieve values from the Android Calculator

查看:144
本文介绍了如何检索来自Android的计算器值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发用户点击的EditText 的应用程序,它显示了android计算器,因此用户能够做算术运算。

I am developing an application which the user taps on EditText, it displays the android calculator, so the user is able to do arithmetic operations.

我想,当用户presses在android计算器平等按钮获取最终值并显示它。这是可能的使用标准Android计算器?

I would like to retrieve the final value when the user presses the equal button in the android calculator and display it. Is that possible using the standard android calculator?

在code打开计算器如下:

The code to open the calculator is the following:

Intent intent = new Intent();           
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(new ComponentName(CALCULATOR_PACKAGE, CALCULATOR_CLASS));
startActivity(intent);

其中,

String CALCULATOR_PACKAGE ="com.android.calculator2";
String CALCULATOR_CLASS ="com.android.calculator2.Calculator";

有关如何检索从计算器终值任何意见或建议?结果
谢谢

Any ideas or suggestion about how to retrieve the final value from the calculator?
Thanks

推荐答案

它使用标准计算器是不可能的,但计算器是开源的,所以你可以创建自己的计算器。源包含一个名为逻辑(Logic.java)类;如果您更新方法evaluateAndShowResult()来自动粘贴结果到剪贴板,然后做一个贴在你的应用程序,你准备好了。

It's not possible using the standard calculator, but that calculator is open source, so you could create your own calculator. The source contains a class called Logic (Logic.java); if you update the method evaluateAndShowResult() to automatically paste the result to the clipboard, and then do a paste in your app, you'd be ready.

作为一种替代方法,如果你真的不需要计算器的用户界面,你可以只取逻辑和垃圾的其余部分。

As an alternative, if you really don't need the calculator's UI, you could just take Logic and trash the rest.

这篇关于如何检索来自Android的计算器值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆