31 Aug 2015, 15:53

Removing an intent-filter using the Android Manifest Merger

Needed to remove an intent-filter for an activity that was defined in a library. This can be done by instructing the Android Manifest Merger with a tools:node="remove" on the intent-filter tag.

To identify a specific intent-filter tag (there can be many), the merger uses the combination of android:name attributes from the child action and category tags.

Example:

<activity
  android:name=".SomeActivity">
  <intent-filter tools:node="remove">
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER"/>
  </intent-filter>
</activity>

12 Mar 2015, 22:14

Finding files in git log

Show all git log entries that concern a certain (existing or non-existing) file path:

git log --all -- <path>

path is a git pathspec that can contain *s and ?s (more info here)

Add a modifier like --stat, --name-status or --name-only for more informative output

Example: Finding when that folder was deleted in order to restore it

git log --all --name-status  -- 'src/test/scala/se/appland/somefolder*'

09 Mar 2015, 10:16

Android WebView Cookies

Had some cookie problems when loading raw content in an Android WebView:

Uncaught SecurityError: Failed to read the 'cookie' property from 'Document': Cookies are disabled inside 'data:' URLs.

It seems that

WebView webView = new WebView(activity);
webView.loadData(htmlString, "text/html", null);

puts us at a ‘data:’ url (which makes sense), where cookies are blocked.

We need to enable cookies and also forcibly set the url to something else, like:

CookieManager.getInstance().setAcceptCookie(true);
WebView webView = new WebView(activity);
webView.loadDataWithBaseURL("http://localhost/", htmlString, "text/html", "utf-8", null);