How to detect power connected state?

前端 未结 5 1433
庸人自扰
庸人自扰 2020-11-30 13:24

Is there an easy way to be notified when USB or AC power is connected to an Android phone?

5条回答
  •  广开言路
    2020-11-30 14:16

    One thing more you must check whether there is errors in Manifest--->application. If then click on the field showing error and just click on the link "Name" Then dialogue box appears for adding a class. add the class and in the class copy the code of on receive.That is the code above should be copied in the class file not the main activity. Thanks Pzycoderz

提交回复
热议问题