体温填报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; }
注:需要权限