为了账号安全,请及时绑定邮箱和手机立即绑定

在核心 Java 中识别安卓设备

在核心 Java 中识别安卓设备

慕村225694 2022-09-22 19:29:06
我正在用核心Java做一个项目,它将一些处理过的文件推送到Android设备。所以我需要的是,我只需要识别连接到我的计算机的Android设备,并将一些文件推送到内部存储。假设设备已连接,并且设备中已授予访问内部存储的权限。
查看完整描述

1 回答

?
弑天下

TA贡献1818条经验 获得超7个赞

//**************************

// The UAgentInfo class encapsulates information about

//   a browser's connection to your web site. 

//   The object's detection methods return booleans: true or false.

public class UAgentInfo

{

   //Stores some info about the browser and device.

   private String userAgent;


   //Stores info about what content formats the browser can display.

   private String httpAccept; 


   // A long list of strings which provide clues 

   //   about devices and capabilities.

   public static final String deviceIphone = "iphone";


   // [ SNIP! Other variables snipped out ] 



   //**************************

   //The constructor. Initializes several default variables.

   public UAgentInfo(String userAgent, String httpAccept) {

        if (userAgent != null) {

            this.userAgent = userAgent.toLowerCase();

        }

        if (httpAccept != null) {

            this.httpAccept = httpAccept.toLowerCase();

        }

    }


   //**************************

   //Returns the contents of the User Agent value, in lower case.

   public String getUserAgent()

   { 

       return userAgent;

   }


   //**************************

   // Detects if the current device is an iPhone.

   public boolean detectIphone()

   {

        //The iPod touch says it's an iPhone! So let's disambiguate.

        if (userAgent.indexOf(deviceIphone) != -1 && !detectIpod()) {

            return true;

        }

        return false;

   }


   // [ SNIP! Other functions snipped out ] 


}


查看完整回答
反对 回复 2022-09-22
  • 1 回答
  • 0 关注
  • 57 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信