小编art*_*ire的帖子

为什么从float转换为double会改变这个值?

我一直试图找出原因,但我不能.有谁能够帮我?

请看下面的例子.

float f = 125.32f;
System.out.println("value of f = " + f);
double d = (double) 125.32f; 
System.out.println("value of d = " + d);
Run Code Online (Sandbox Code Playgroud)

这是输出:

值f = 125.32

值d = 125.31999969482422

java floating-point precision double ieee-754

16
推荐指数
3
解决办法
2万
查看次数

构建错误运行cordova平台添加android

我正在尝试根据以下链接创建Android PhoneGap项目:http://docs.phonegap.com/en/edge/guide_platforms_android_index.md.html

但是,当我运行命令时:

cordova platform add android
Run Code Online (Sandbox Code Playgroud)

我得到以下输出:

Checking Android requirements...
Creating android project...
[Error: An error occured during creation of android sub-project. Looks like your environment fully supports cordova-android development!
Creating Cordova project for the Android platform:
Path: platforms/android
    Package: com.example.hello
    Name: HelloWorld
    Android target: android-17
Building cordova-3.2.0-rc1.jar

{ [Error: Command failed: 
BUILD FAILED
/path/to/adt/sdk/tools/ant/build.xml:653: The following error occurred while executing this line:
/path/to/adt/sdk/tools/ant/build.xml:698: null returned: 127

Total time: 1 second
] killed: false, code: 1, …
Run Code Online (Sandbox Code Playgroud)

android cordova

7
推荐指数
2
解决办法
7672
查看次数

没有对等证书异常 - 具有自签名证书的Volley和Android

我正在尝试让我的应用通过https与我的服务器通信.由于我不想付费以获得由受信任的CA签署的服务器证书,因此解决方案是使用自签名证书.

所以,我创建了我的caconfig.cnf如下:

[ ca ]
default_ca              = CA_default                    # The default ca section

[ CA_default ]
dir                     = ./demoCA                      # top dir
database                = $dir/index.txt                # index file.
new_certs_dir           = $dir/newcerts                 # new certs dir

certificate             = $dir/cacert.pem               # The CA cert
serial                  = $dir/serial                   # serial no file
private_key             = $dir/private/cakey.pem        # CA private key
RANDFILE                = $dir/private/.rand            # random number file

default_days            = 365                           # how long to certify for
default_crl_days        = 30                            # how long before next …
Run Code Online (Sandbox Code Playgroud)

https android self-signed node.js android-volley

6
推荐指数
1
解决办法
1142
查看次数

调用finish()后活动布局闪烁

当我打开我的应用程序时,会启动一个Activity,并且在其onCreate方法中我正在检查某些条件.如果条件为真,我完成当前活动并打开另一个活动.问题是:第一个活动在屏幕上闪烁,然后第二个活动打开.代码如下:

public class FirstActivity extends Activity {
    @Override
    protected final void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //some code here...
        checkSomeStuff();
        setContentView(R.layout.my_layout);
        //some code here...
    }
    private void checkSomeStuff() {
        if (/*some condition*/) {
            final Intent intent = new Intent(this, SecondActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            finish();
            startActivity(intent);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

请注意,setContentView()在检查之后,但在第二个活动开始之前,第一个活动仍然在屏幕上闪烁.有谁知道怎么让它不眨眼?

提前致谢.

android activity-lifecycle android-activity

3
推荐指数
1
解决办法
5228
查看次数