Android – DialogFragment setStyle

Android

//1 -> style = DialogFragment.STYLE_NO_TITLE
//2 -> style = DialogFragment.STYLE_NO_FRAME
//3 -> style = DialogFragment.STYLE_NO_INPUT
//4 -> style = DialogFragment.STYLE_NORMAL
//            --
//4 -> theme = android.R.style.Theme_Holo
//5 -> theme = android.R.style.Theme_Holo_Light_Dialog
//6 -> theme = android.R.style.Theme_Holo_Light
//7 -> theme = android.R.style.Theme_Holo_Light_Panel
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Holo_Light_Dialog)

Android – Calculando a intensidade do sinal wifi (Getting WiFi signal strength in Android)

android wifi

WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
int numberOfLevels = 5;
WifiInfo wifiInfo = wifiManager.getConnectionInfo();Referência
int level = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels);

Referência: https://developer.android.com/reference/android/net/wifi/WifiManager.html#calculateSignalLevel%28int,%20int%29

Android – Desabilitar o recurso multi window programaticamente (Disable multi window feature programatically)

multi-window

Normalmente presente em dispositivos da samsung. Para desabilitar o recurdo multi-window basta executar o seguinte comando:

// requer permissão: android:name="android.permission.WRITE_SETTINGS"
// 0=desabilitado ; 1=habilitado
Settings.System.putInt(contentResolver, "multi_window_enabled", 0)

Android – Esconder o teclado do android programaticamente ‘forçado’ (Hide keyboard programmatically)

keyboard_android

easy workaround:

           InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
           imm.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), 0);

Android – Como converter um byte[] em um objeto Mat utilizando o OpenCV no Android (How to get the Mat object from the Byte[] in openCV android?)

open_cv
Simples assim:

Mat mat = Imgcodecs.imdecode(
    new MatOfByte(bytes), Imgcodecs.CV_LOAD_IMAGE_UNCHANGED
);

Como converter um Bitmap em um objeto Mat:

import org.opencv.android.Utils;

Mat mat = new Mat();    
Bitmap bmp32 = bmp.copy(Bitmap.Config.ARGB_8888, true);
Utils.bitmapToMat(bmp32, mat);

Android – Detecção facial utilizando o OpenCV (OpenCV in Android Studio with face detect)

open_cv

Detecção facial utilizando OpenCV no Android – OpenCV in Android Studio with face detect

This application is a sample Android Studio project (tested on gradle 3.0.1) with ‘Android SDK OpenCV 3.3.1′

Project: https://github.com/helpdeveloper/AndroidFaceDetectOpenCV

Usage:

Here is how to use this project to run native OpenCV code.

  • Make sure you have Android SDK up to date, with NDK installed
  • Download latest OpenCV SDK for Android from OpenCV.org and decompress the zip file.
  • Clone this project
  • Create a symlink named jniLibs in app/src/main that points to YOUR_OPENCV_SDK/sdk/native/libs
  • In app/CMakeLists.txt change line 9 to points to YOUR_OPENCV_SDK/sdk/native/jni/include
  • Sync gradle
  • Run the application

-> README FILE -<

 

Android / Gradle 3.0.X – Error:All flavors must now belong to a named flavor dimension. Learn more at ….

gradle

Erro: todos os sabores devem agora pertencer a uma dimensão de sabor nomeada.

Simples solução, em seu build.gradle:

android{
    ...
    flavorDimensions "default"
    productFlavors{
        flavor1{...}
        flavor2{...}
    }
}

Claro que ficou bem mais abrangente os flavors, para mais informações: https://developer.android.com/studio/build/build-variants.html#flavor-dimensions