Skip to content

Instantly share code, notes, and snippets.

View jaydeepw's full-sized avatar

JW jaydeepw

View GitHub Profile
@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";
}