Guest User

Untitled

a guest
Feb 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. package com.larocheent.antiscreendim;
  2.  
  3. import android.content.BroadcastReceiver;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.os.Bundle;
  7. import android.os.PowerManager;
  8. import android.telephony.TelephonyManager;
  9. import android.util.Log;
  10.  
  11. public class AntiScreenDimActivity extends BroadcastReceiver {
  12.     private PowerManager.WakeLock wl;
  13.  
  14.     @Override
  15.     public void onReceive(Context context, Intent intent) {
  16.         Bundle extras = intent.getExtras();
  17.         if (extras != null) {
  18.             String state = extras.getString(TelephonyManager.EXTRA_STATE);
  19.             Log.w("DEBUG", state);
  20.            
  21.             if(state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
  22.                 Log.w("Phone State", "Active call in session");
  23.                 PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
  24.                 wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "DoNotDimScreen");
  25.                 wl.acquire();
  26.  
  27.             }
  28.         }
  29.     }
  30.    
  31. }
Add Comment
Please, Sign In to add comment