Android: Detecting USB

前端 未结 6 1853
一生所求
一生所求 2020-11-27 06:13

Is there any way to know(programmatically) in your Activity/Application that the user has connected your phone to PC through USB?

6条回答
  •  庸人自扰
    2020-11-27 06:30

    Manifest.xml:

    
        
            
        
    
    

    MyReceiver:

    public class MyReceiver extends BroadcastReceiver{
    if (intent.getAction().equalsIgnoreCase(
            "android.intent.action.UMS_CONNECTED")) {...}
    }
    

提交回复
热议问题