Skip to content

Instantly share code, notes, and snippets.

View jaydeepw's full-sized avatar

JW jaydeepw

View GitHub Profile
@jaydeepw
jaydeepw / enableHTML5AppCache.java
Last active October 5, 2023 11:39
Enabling HTML5 AppCache in Android Webview programatically.
private void enableHTML5AppCache() {
webView.getSettings().setDomStorageEnabled(true);
// Set cache size to 8 mb by default. should be more than enough
webView.getSettings().setAppCacheMaxSize(1024*1024*8);
// This next one is crazy. It's the DEFAULT location for your app's cache
// But it didn't work for me without this line
webView.getSettings().setAppCachePath("/data/data/"+ getPackageName() +"/cache");
@jaydeepw
jaydeepw / is-android-service-running
Created May 15, 2012 06:43
Android: Checking if a Service is already running in the Android system.
private boolean isMyServiceRunning() {
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if ("com.example.MyService".equals(service.service.getClassName())) {
return true;
}
}
return false;
}
@jaydeepw
jaydeepw / blackberry-network-connection-string.java
Created April 24, 2012 16:18
Getting a connection string while making a network connection in BlackBerry.
// Get most appropriate connection method
private String getConnectionString() {
String suffix = null;
if (CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_MDS))
{
// BES is available
suffix = ";deviceside=false";
}