如何检查Android应用是否在真实设备或虚拟设备中运行?

时间:2015-09-23 06:34:40

标签: android android-emulator genymotion

我想检查真实设备用户或虚拟设备用户(如AVD,Genymotion,bluestack之类的东西)

我的应用已检查设备ID并获得奖励。 如果滥用用户在虚拟设备中运行应用程序,您现在我将成为一个乞丐:(

1 个答案:

答案 0 :(得分:3)

您可以使用以下支票:

@RequestMapping(method = {RequestMethod.GET})
public ResponseEntity<byte[]> start() throws Exception {
    FileInputStream fi = new FileInputStream(new File("/tmp/test.pdf"));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    int c;
    while ((c = fi.read()) != -1) {
        baos.write(c);
    }

    fi.close();
    byte[] pdf = baos.toByteArray();
    baos.close();

    response.setHeader("Expires", "0");
    response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
    response.setHeader("Pragma", "public");

    response.setHeader("Content-Disposition", "inline; filename=sureshbabu.pdf");
    response.setContentType("application/pdf");
    response.setContentLength(pdf.length);
    response.getOutputStream().write(pdf);
    response.getOutputStream().flush();

    return null;
}