- Implement your BlockService.kt (Sample: MyBlockService.kt)
- Implement when to use block (Sample AirPlaneIntentReceiver.kt: When device into in air plane mode, call service.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package br.com.helpdev; | |
| import javax.imageio.IIOImage; | |
| import javax.imageio.ImageIO; | |
| import javax.imageio.ImageWriteParam; | |
| import javax.imageio.ImageWriter; | |
| import javax.imageio.stream.ImageOutputStream; | |
| import java.awt.*; | |
| import java.awt.image.BufferedImage; | |
| import java.io.*; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.File; | |
| import java.io.FileInputStream; | |
| import java.io.FileNotFoundException; | |
| import java.io.FileOutputStream; | |
| import java.io.IOException; | |
| import java.io.InputStream; | |
| import java.util.Base64; | |
| /** | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class YuvHelper { | |
| public static byte[] rotateYUV420Degree90(byte[] data, int imageWidth, | |
| int imageHeight) { | |
| byte[] yuv = new byte[imageWidth * imageHeight * 3 / 2]; | |
| // Rotate the Y luma | |
| int i = 0; | |
| for (int x = 0; x < imageWidth; x++) { | |
| for (int y = imageHeight - 1; y >= 0; y--) { | |
| yuv[i] = data[y * imageWidth + x]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.app.Activity; | |
| import android.content.Context; | |
| import android.graphics.PixelFormat; | |
| import android.view.Gravity; | |
| import android.view.MotionEvent; | |
| import android.view.ViewGroup; | |
| import android.view.WindowManager; | |
| /** | |
| * <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun getMobileDataEnabled(contentResolver: ContentResolver):Boolean{ | |
| return 1 == Settings.Global.getInt(contentResolver, "mobile_data", 1) | |
| } | |
| fun hasIccCard(context:Context):Boolean{ | |
| val systemService = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager | |
| return systemService.hasIccCard() | |
| } | |
| fun startScreenDataMobile(context:Context){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AirPlaneIntentReceiver : BroadcastReceiver() { | |
| override fun onReceive(context: Context, intent: Intent) { | |
| val isAirplaneModeOn = intent.getBooleanExtra("state", false) | |
| if (isAirplaneModeOn) { | |
| //TODO - ENABLED | |
| } else { | |
| //TODO - DISABLED | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // CRIAR SERVIÇO PARA INTERCEPTAR NOTIFICAÇES: | |
| class NotificationService : android.service.notification.NotificationListenerService() { | |
| override fun onCreate() { | |
| super.onCreate() | |
| } | |
| override fun onNotificationPosted(sbn: StatusBarNotification) { | |
| } | |
| override fun onNotificationRemoved(sbn: StatusBarNotification) { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val locationMode = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE); | |
| when (locationMode) { | |
| Settings.Secure.LOCATION_MODE_OFF -> {/*TODO*/} | |
| Settings.Secure.LOCATION_MODE_HIGH_ACCURACY ->{/*TODO*/} | |
| Settings.Secure.LOCATION_MODE_BATTERY_SAVING -> {/*TODO*/} | |
| Settings.Secure.LOCATION_MODE_SENSORS_ONLY -> {/*TODO*/} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import android.content.ContentResolver; | |
| import android.provider.Settings; | |
| /** | |
| * Created by Guilherme Biff Zarelli on 2/26/18. | |
| */ | |
| public class BrightnessUtils { | |
| private BrightnessUtils() { | |
| throw new RuntimeException("No BrightnessUtils"); |
OlderNewer