Blogger Information
Blog 143
fans 1
comment 0
visits 439815
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
H5+ Android 监听USB 连接状态
弘德誉曦的博客
Original
1498 people have browsed it

王者地带 - 5+混合APP开发教程网 | http://www.html5-app.com  | ***: 2564034335 

的回复:

 var main = plus.android.runtimeMainActivity();    
          var receiver = plus.android***plements('io.dcloud.feature.internal.reflect.BroadcastReceiver',{onReceive:getReceive});  
          var IntentFilter = plus.android***portClass('android.content.IntentFilter');  
          var Intent = plus.android***portClass('android.content.Intent');   
          var filter= new IntentFilter();  
          var action="android.hardware.usb.action.USB_STATE";  
              filter.addAction(action);   
              main.registerReceiver(receiver, filter);          
              function getReceive(context,intent)  
              {   
                   var type= intent.getAction();   
                       if(type==action)  
                       {  
                         var connected=intent.getExtras();   
                         plus.android***portClass(connected);   
                         var isusb=connected.getBoolean("connected");  
                             if(isusb)  
                             {  
                                 uni.showToast({title:"USB 已连接",icon:"none"});   

                             }else{  

                                 uni.showToast({title:"USB 已拔出",icon:"none"});   
                             }   
                       }   
              }


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post