Send event of scrolling from ScrollView to the WebView JavaScript code

GitHub: https://github.com/Pulimet/ScrollViewEventTest

First in onCreate() we will set our WebView:

private WebView mWebView;
private ScrollView mScrollView;
public static final long DELAY_TIME = 1000;
private long mTime;
...
mWebView = findViewById(R.id.webView);
mWebView.loadUrl("http:///www.alexandroid.net");

Enable JavaScript:

WebSettings webViewSettings = mWebView.getSettings();
webViewSettings.setJavaScriptEnabled(true);

Create a method that would invoke our JavaScript code:

private void invokeJavaScriptCode(String code) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    mWebView.evaluateJavascript(code, null);
  } else {
    mWebView.loadUrl(String.format("javascript:%s", code));
  }
}

Keep Reading

A collection of useful links for Android developers

I found a convenient way to organize websites that proved to be useful, during the process of developing Android apps.

I organized them in my Trello board (called “Android Developer Links“), combined with the gorgeous Google Chrome extension that is “Trello Card Links“.

I will keep updating this list on an almost daily basis, so feel free to check them out and offer other useful tools yourselves – just post then in the comments below!

Indicators library

Recently, I created a custom view, and after having used it for several of my projects, I decided to publish it as a library.

How to use it: https://github.com/Pulimet/Indicators-Library

<net.alexandroid.utils.indicators.IndicatorsView
    android:id="@+id/indicatorsView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

    app:indicatorSize="20dp"
    app:paddingBetweenIndicators="16dp"

    app:selectedDrawable="@drawable/custom_selected"
    app:unSelectedDrawable="@drawable/custom_unselected"/>

Run signed apk on your device via Android Studio

  1. Open local.properties and add there keystore location, alias and password:This file must NOT be checked into Version Control Systems, as it contains information specific to your local configuration and password now.
    password=your_password
    keystore=C\:/keystore_location/keystore.jks 
    alias=your_alias
  2. Add signingConfigs at build.gardle of the module:
    android {
    ...
        signingConfigs {
            release {
            keyAlias alias
            keyPassword password
            storeFile file(keystore)
            storePassword password
            }
        }
    ...
    }
  3. Add build types:
    android {
    ...
        buildTypes {
            debug {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('p.txt'), 'proguard-rules.pro'
                shrinkResources true
            }
            release {
                minifyEnabled true
                proguardFiles getDefaultProguardFile('p.txt'), 'proguard-rules.pro'
                shrinkResources true
                signingConfig signingConfigs.release
            }
        }
    ...
    }
  4. Before running choose build variant:
    Capture

Gps Detector Library

What does the library do for you?

  1.  It checks whether GPS is enabled in your device. If it’s already enabled – you’ll be informed about it.
  2. In case that GPS is disabled, a dialog will appear (as can be seen on the right). Once you press “accept”, the GPS will be turned on.

The library speeds up the GPS enabling process, by sparing the user to change the settings in the android system.

So, let’s figure out how to use it.

Keep Reading