体温填报app2.0开发

读取本机手机号与自动登录功能的实现。

TelephonyManager tm = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
        String pho =  tm.getLine1Number();
        boolean phe = us.userphone(pho);
        if(phe)
        {
            Intent intent=new Intent(ZC.this,P.class);
            startActivity(intent);
        }
public boolean userphone(String pho)
    {

        SQLiteDatabase sdb=dbHelper.getReadableDatabase();
        String sql="select * from user where tel=?";
        Cursor cursor=sdb.rawQuery(sql, new String[]{pho});
        if(cursor.moveToFirst()==true)
        {
            User user=new User();
            String name = cursor.getString(cursor.getColumnIndex("name"));
            user.setName(name);
            cursor.close();
            return true;
        }
        return false;
    }

注:需要权限

posted @ 2021-03-05 18:01  谦寻  阅读(39)  评论(0编辑  收藏  举报