Micro blog about Answer to the Ultimate Question of Life, the Universe, and Everything.
  • Home
    • List all categories
    • Sitemap
  • Downloads
    • WebSphere
    • Hitachi902
    • Hospital
    • Kryptonite
    • OCR
    • APK
  • About me
    • Gallery
      • Italy2022
      • Côte d'Azur 2024
    • Curriculum vitae
      • Resume
      • Lebenslauf
    • Social networks
      • Facebook
      • Twitter
      • LinkedIn
      • Xing
      • GitHub
      • Google Maps
      • Sports tracker
    • Adventures planning
  1. You are here:  
  2. Home

Global exception handler

Details
Written by: Stanko Milosev
Category: Android
Published: 15 December 2015
Last Updated: 15 December 2015
Hits: 3899

There is possibility in Android to set global exception handler. My code looks something like this:

public class BrowserActivity extends Activity {
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            if(!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
                Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(this));
            }
    }
}

Where CustomExceptionHandler can look like this:

public class CustomExceptionHandler implements Thread.UncaughtExceptionHandler {
    @Override
    public void uncaughtException(Thread t, Throwable e) {
        //do something here
    }
}

Set the version

Details
Written by: Stanko Milosev
Category: Android
Published: 09 December 2015
Last Updated: 09 December 2015
Hits: 3821

For example, read version from JSON file. In build.gradle, in my case it is in: /app/build.gradle write something like:

def computeVersionName() {
    def f1 = new File("app/src/main/assets/version.json");
    def json = new JsonSlurper().parseText(f1.text)

    assert json instanceof Map
    return json.version
}

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId 'myId'
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 2
        versionName computeVersionName()
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

Notice:

versionName computeVersionName()

Video tag in WebView

Details
Written by: Stanko Milosev
Category: Android
Published: 25 November 2015
Last Updated: 25 November 2015
Hits: 4973

It seems that androids WebView doesn't like video tag.

Here is Android code which worked for me:

        mWebView.setWebViewClient(new WebViewClient() {
            // autoplay when finished loading via javascript injection
            public void onPageFinished(WebView view, String url) {
                mWebView.loadUrl("javascript:(function() { document.getElementsByTagName('video')[0].play(); })()");
            }
        });

        mWebView.setWebChromeClient(new WebChromeClient());

Where WebChromeClient we need to handle javascript methods, and it seems that autoplay in WebView doesn't work.

Also, mWebView is: private WebView mWebView; (I took example of WebView based application)

HTML code looks like:

<video autoplay loop>
	<source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
</video>

Inspect WebView

Details
Written by: Stanko Milosev
Category: Android
Published: 28 August 2015
Last Updated: 04 November 2015
Hits: 4164

To debug your web application in Android in Chrome write:

chrome://inspect/#devices

and click inspect:

Before that in Android code write:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  WebView.setWebContentsDebuggingEnabled(true);
}

  1. Load local file in the WebView
  2. Installing Android studio on Ubuntu
  3. Manually installing factory image on Nexus 5
  4. My list of best applications

Subcategories

C#

Azure

ASP.NET

JavaScript

Software Development Philosophy

MS SQL

IBM WebSphere MQ

MySQL

Joomla

Delphi

PHP

Windows

Life

Lazarus

Downloads

Android

CSS

Chrome

HTML

Linux

Eclipse

Page 147 of 163

  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151