Blog

  • Android Keyboard. LatinIME gradle module

    Android Keyboard. LatinIME gradle module

    My application requires Android keyboard.
    I’ve got LatinIME from AOSP and made gradle module.

    LatinIME support Android Accessibility and works perfect with TalkBack.

    Here is screenshots:

    screenshot_2016-11-17-00-49-59

    screenshot_2016-11-17-00-50-03

     

     

     

     

     

     

    Here is link for my github repo:

    Download it from github
  • How to fix “undefined reference to ‘__atomic_exchange_4”

    How to fix “undefined reference to ‘__atomic_exchange_4”

    When I built native library for LatinIME I’ve got next error:

    undefined reference to ‘__atomic_exchange_4

    Full stacktrace:

    /Volumes/Android/buildbot/src/android/ndk-r13-release/external/libcxx/include/memory:635: error: undefined reference to '__atomic_load_4'
    /Volumes/Android/buildbot/src/android/ndk-r13-release/external/libcxx/../../external/libcxxabi/src/cxa_handlers.cpp:112: error: undefined reference to '__atomic_exchange_4'
    /Volumes/Android/buildbot/src/android/ndk-r13-release/external/libcxx/../../external/libcxxabi/src/cxa_default_handlers.cpp:106: error: undefined reference to '__atomic_exchange_4'
    /Volumes/Android/buildbot/src/android/ndk-r13-release/external/libcxx/../../external/libcxxabi/src/cxa_default_handlers.cpp:117: error: undefined reference to '__atomic_exchange_4'
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [obj/local/armeabi/libjni_latinime.so] Error 1

    To avoid it open Android.mk file and add next string:

    LOCAL_EXPORT_LDLIBS += -latomic
  • Build native libs for LatinIME. Error: base class ‘class latinime::NgramListener’ should be explicitly initialized in the copy constructor [-Werror=extra]

    Build native libs for LatinIME. Error: base class ‘class latinime::NgramListener’ should be explicitly initialized in the copy constructor [-Werror=extra]

    I working on LatinIME Android Keyboard keyboard.

    I’ve got source from Google repo.
    Here is structure:

    java – contains java code
    native – jni code.

    When I try to build native I receive next error:

    'latinime::MultiBigramMap::BigramMap::BigramMap(const latinime::MultiBigramMap::BigramMap&)':
    jni/src/suggest/core/dictionary/multi_bigram_map.h:56:9: error: base class 'class latinime::NgramListener' should be explicitly initialized in the copy constructor [-Werror=extra]

    Full stacktrace:

    ➜ native ndk-build
    [arm64-v8a] Compile++ : jni_latinime_common_static <= com_android_inputmethod_keyboard_ProximityInfo.cpp
    [arm64-v8a] Compile++ : jni_latinime_common_static <= com_android_inputmethod_latin_BinaryDictionary.cpp
    [arm64-v8a] Compile++ : jni_latinime_common_static <= com_android_inputmethod_latin_BinaryDictionaryUtils.cpp
    [arm64-v8a] Compile++ : jni_latinime_common_static <= com_android_inputmethod_latin_DicTraverseSession.cpp
    In file included from jni/src/suggest/core/session/dic_traverse_session.h:25:0,
    from jni/com_android_inputmethod_latin_DicTraverseSession.cpp:24:
    jni/src/suggest/core/dictionary/multi_bigram_map.h: In copy constructor 'latinime::MultiBigramMap::BigramMap::BigramMap(const latinime::MultiBigramMap::BigramMap&)':
    jni/src/suggest/core/dictionary/multi_bigram_map.h:56:9: error: base class 'class latinime::NgramListener' should be explicitly initialized in the copy constructor [-Werror=extra]
    BigramMap(const BigramMap &bigramMap)
    ^
    cc1plus: all warnings being treated as errors
    make: *** [obj/local/arm64-v8a/objs/jni_latinime_common_static/com_android_inputmethod_latin_DicTraverseSession.o] Error 1

    To avoid it I’ve edited Android.mk in jni dir and replace:

    LOCAL_CFLAGS += -Werror -Wall -Wextra -Weffc++ -Wformat=2 -Wcast-qual -Wcast-align \
        -Wwrite-strings -Wfloat-equal -Wpointer-arith -Winit-self -Wredundant-decls \
        -Woverloaded-virtual -Wsign-promo -Wno-system-headers

    with

    LOCAL_CFLAGS += -w

    It is not remove the code problem, but you able to build .so lib

  • How to flash Nexus 5 Hammerhead

    How to flash Nexus 5 Hammerhead

    Hi Guys,

    Please do the next instructions with your own risk.

    1. Download stock Image from https://developers.google.com/android/nexus/images
    2. I’ve downloaded 6.0.1 (MOB31E)
    3. Inzip Image
    4. Unlock the device’s bootloader
      fastboot flashing unlock

      or, for older devices, run the next:

      fastboot oem unlock
    5. Execute the flash-all script from ZIP.Screenshot 2016-09-22 02.20.40
    6. Start the device in fastboot mode again.
    7. Lock device bootloader:
      fastboot flashing lock

      or, for older devices, running:

      fastboot oem lock
  • How to root Nexus 5 without PC or Mac

    How to root Nexus 5 without PC or Mac

    Attention! Use it at your own risk.
    1. You can turn your smartphone into a brick.
    2. Your phone warranty turns void.
    3. Malware can easily breach your mobile security.

    I’ve rooted my Nexus 5 using KingRoot service.
    High recommended for fast rooting.

    kingroot.net

  • Android: PocketSphinx speech/voice recognition library in background.

    Android: PocketSphinx speech/voice recognition library in background.

    As you know we have Google Voice for voice recognition.

    Here is simple way to implement offline speech recognition using PocketSphinx lib.

    I’ve created simple app which will run Service with speech recognition functionality.

    You can add one keyword here:

    recognizer.addKeyphraseSearch(KWS_SEARCH, KEYPHRASE);

    Sure PocketSphinx have multi-keyword functionality.

    File menuGrammar = new File(assetsDir, "voicecommands.gram");
    recognizer.addGrammarSearch(VOICE_COMMAND, menuGrammar);

    But for me it is’t perfect.

    One-word mode works better.

    Use PocketSphinx if you need only one-keyphrase recognition.

    Here is full documentation:

    http://cmusphinx.sourceforge.net/wiki/tutorialandroid

    My sample project on github

    Download it from github
  • How to answer incoming call programmatically in Android

    How to answer incoming call programmatically in Android

    Here is example for accepting incoming calls programmatically

    The most stable version is using adb shell feature.

    Call can be answered by sending command “adb shell input keyevent 79” via Terminal

    Same thing can be done programmatically.

    But, it works good for user-driven answering and this solution good for custom call screen.
    It will not work for any sort of automated call-control-type applications.
    Like auto answering via BroadcastReceivers etc.

    Screenshot 2016-05-26 13.54.20

    try {
        Runtime.getRuntime().exec("input keyevent " + Integer.toString(KeyEvent.KEYCODE_HEADSETHOOK));
    } catch (IOException e) {
       //handle error here
    }

    Awaiting comments. Let me know the better ways.

  • Epson XP-103 ink pad counter reset for FREE

    Epson XP-103 ink pad counter reset for FREE

    My printer has stop working and “paper” and “ink” start blinking.

    This happens when printer’s ink pads are full

    From manual:
    Screenshot 2016-05-23 01.16.54
    “The printer’s ink pads are nearing or at the end of their service life. Contact Epson Support to replace ink pads. When the printer’s ink pads are nearing the end of their service life, you can resume printing by pressing x r or r x. The paper light and the ink light ash alternately.”

    I’ve opened printer and clean ink pads.

    After that I need reset counter. To do it I’ve downloaded iWIC tool software.

    WIC Reset Utility for Windows (ZIP, 2.56 mB)
    iWIC for Mac OS 10.6 Intel and higher (iWIC.dmg)
    WIC for Linux

    Download Free

    Screenshot 2016-05-23 01.20.19

    This software require key. But you can use “trial” or “TRIAL” software for one free resetting.

    Hope it helps.

    Let me know if you know better FREE method. I’ll need it in future 🙂

  • Image loading in Android.

    Image loading in Android.

    There a lot libraries for loading images. Lets talk about couple of them.

    1. Picasso (http://square.github.io/picasso/)

    dependency

    dependencies {
        compile 'com.squareup.picasso:picasso:2.5.1'
    }

    This library easy to use. To load image from url to ImageView you need do just one line.

    Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);
    

    Current library have a features which can be useful for your app:

      • Image transformation
    Picasso.with(context)
      .load(url)
      .resize(50, 50)
      .centerCrop()
      .into(imageView)
      • Placeholder for progress and error. Useful to show some drawable if downloading failed or in progress
    Picasso.with(context)
        .load(url)
        .placeholder(R.drawable.user_placeholder)
        .error(R.drawable.user_placeholder_error)
        .into(imageView);
      • Using Picasso you can load images from resources, file or web
    Picasso.with(context).load(R.drawable.landing_screen).into(imageView1);
    Picasso.with(context).load("file:///android_asset/DvpvklR.png").into(imageView2);
    Picasso.with(context).load(new File(...)).into(imageView3);
    1. Glide (https://github.com/bumptech/glide)

    Current library is recommended by Google.

    dependency

    dependencies {
        compile 'com.github.bumptech.glide:glide:3.5.2'
        compile 'com.android.support:support-v4:22.0.0'
    }

    Usage:

    Glide.with(this).load("http://goo.gl/gEgYUd").into(imageView);

    Also Glide has a features:

    Glide
        .with(myFragment)
        .load(url)
        .centerCrop()
        .placeholder(R.drawable.loading_spinner)
        .crossFade()
        .into(myImageView);

    I use Glide because:
    1. Faster than Picaso
    2. Have better “.with()” method. Glide.with(this) can take Context, Fragment, Activity, etc.

    Currently Glide better Image loader library.

    Awaiting your comments.

  • iPhone to Android and Android to iPhone density converter

    iPhone to Android and Android to iPhone density converter

    I use this coefficients when I need convert iOS assets to Android or Android to iOS.

    MDPI / BASE = 100

    TVDPI = 133

    HDPI = 150

    XHDPI / RETINA = 200

    XXHDPI = 300

    XXXHDPI = 400