마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

안드로이드 충전해제시 어플을 실행하려고하는데 도와주세요

0 추천
따로 예제가 있는것도아니라서 어렵네요...

에제가 잇거나 아니면 소스가 있다면 올려주실수있나요..?
익명사용자 님이 2016년 7월 18일 질문

1개의 답변

0 추천

 

 

In AndroidManifest.xml

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <receiver android:name=".receiver.PlugInControlReceiver">
        <intent-filter>
            <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
            <action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
        </intent-filter>
    </receiver>
</application>


In Code

public class PlugInControlReceiver extends BroadcastReceiver {
   public void onReceive(Context context , Intent intent) {
       String action = intent.getAction();

       if(action.equals(Intent.ACTION_POWER_CONNECTED)) {
           // Do something when power connected
       }
       else if(action.equals(Intent.ACTION_POWER_DISCONNECTED)) {
           // Do something when power disconnected
       }
   }
}

김조조 (5,540 포인트) 님이 2016년 7월 19일 답변
저 디스커넥트에 인텐트로 메인엑티비티를 실행하면되나요???
...