Saturday, September 29, 2018

Improve WebVIew Performance Load Faster with WebSettings | Android App from Responsive Website - 5

Very nice code by this video :
Published on 11 Nov 2015

Creating Android App from Responsive Website with WebView In this video i will explain about how to improve WebView performance with WebSettings

Failed to resolve: com.google.android.gms:play-services in IntelliJ Idea with gradle

Credit goes to : StackOverflow

I had the issue when I put jcenter() before google() in project level build.gradle. When I changed the order and put google() before jcenter() in build.gradle the problem disappeared
Here is my final build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Wednesday, September 26, 2018

Failed to resolve: com.android.support:appcompat-v7:26.0.0

credit goes to : StackOverflow

To use support libraries starting from version 26.0.0 you need to add Google's Maven repository to your project's build.gradle file as described here: https://developer.android.com/topic/libraries/support-library/setup.html
allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }
For Android Studio 3.0.0 and above:
allprojects {
        repositories {
            jcenter()
            google()
        }
    }

Friday, September 14, 2018

Gradle build error when trying to Generate Signed Apk

Credit goes to : StackOverflow

6 down vote accepted
It's a lintValidRelease issue. You need an add lintOptions in Gradle file.
android {
..
     lintOptions {

        checkReleaseBuilds false

    }
}
  • Thank You! that would work but what i did was that i connected to the internet when generating the signed Apk and by itself it did the magic – Micklo_Nerd Apr 2 at 8:56
  • 3
    Adding lintOptions works, but it seems like a workaround. What is the root cause? I'm connected to the internet and it doesn't help. – 0xF Apr 5 at 18:42
  • I would also like to find root cause for this. suddenly my CircleCi started throwing me this error Execution failed for task 'app:lintVitalRelease'. > Could not resolve all files for configuration 'app:lintClassPath'. > Could not find lint-checks.jar (com.android.tools.lint:lint-checks:26.1.2). Searched in the following locations: https://jcenter.bintray.com/com/android/tools/lint/lint-checks/26.1.2/lint-checks-26.1.2.jar – Rohit Karadkar May 28 at 14:54

Thursday, September 6, 2018

How to avoid restarting activity when orientation changes on Android

Credit goes to StackOverflow
I am creating an Android app in which I'm drawing a view on a canvas. When the device's orientation changes, the activity restarts. I don't want it to.
How can I avoid restarting the activity when the orientation changes?
 
Define your activity in the AndroidManifest.xml like this:
   <activity
        android:name="com.name.SampleActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:icon="@drawable/sample_icon"
        android:label="@string/sample_title"
        android:screenOrientation="portrait" >
    </activity>
 

How to go back to previous page if back button is pressed in WebView?


Credit goes to StackOverFlow

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK:
                if (mWebView.canGoBack()) {
                    mWebView.goBack();
                } else {
                    finish();
                }
                return true;
        }

    }
    return super.onKeyDown(keyCode, event);
}
 
 
=======================
 
For this code to work, you need to add a field to the Activity containing the WebView:
private WebView mWebView; Initialize it in the onCreate() method and you should be good to go.
mWebView = (WebView) findViewById(R.id.webView);