小编Ste*_*fan的帖子

如何检测android上的屏幕压力?

我想得到屏幕的压力.生病时,应用程序向我显示一条消息,Unfortunately, Application has stopped.我有另一个问题,当生病得到屏幕的压力可以转换成一个数学或物理的重量()?这是我的代码:

编辑:我在平板电脑上运行此应用程序

package com.realscale.stefanrafa;

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MotionEvent;
    import android.widget.TextView;

    public class MainActivity extends Activity {

        TextView textinfo;
        MotionEvent pressure;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            textinfo = (TextView) findViewById(R.id.Information);

            float press = pressure.getPressure();
            textinfo.setText("Scale: " + (int) press);
        }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        } …
Run Code Online (Sandbox Code Playgroud)

android android-screen

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

标签 统计

android ×1

android-screen ×1