This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get most appropriate connection method | |
private String getConnectionString() { | |
String suffix = null; | |
if (CoverageInfo.isCoverageSufficient(CoverageInfo.COVERAGE_MDS)) | |
{ | |
// BES is available | |
suffix = ";deviceside=false"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a class member variable. | |
WifiManager.WifiLock mWifiLock = null; | |
/*** | |
* Calling this method will aquire the lock on wifi. This is avoid wifi | |
* from going to sleep as long as <code>releaseWifiLock</code> method is called. | |
**/ | |
private void holdWifiLock() { | |
WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For some help with the Utils class, you may want to take a look | |
// at the following android-utils library. | |
// https://github.com/jaydeepw/android-utils | |
private Uri mOutputFileUri; | |
private void openPhotoChooser() { | |
// Determine Uri of camera image to save |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<target name="launchApp"> | |
<!-- | |
For e.g. adb shell am start -n com.myorg.packagename/com.myorg.activity.package.ActivityName | |
--> | |
<exec executable="adb"> | |
<arg value="shell" /> | |
<arg value="am" /> | |
<arg value="start" /> | |
<arg value="-n" /> | |
<arg value="com.myorg.packagename/com.myorg.activity.package.ActivityName" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/w3c | |
https://github.com/w3c-webmob |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Nullable | |
/** | |
* Converts {@link retrofit.client.Response#body} to simple {@link java.lang.String} representation. | |
* This can be used to log message or manually parse JSON or any other purpose. | |
* @param response | |
* @return | |
*/ | |
public static String toString(@NonNull Response response) { | |
if (response == null) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns a string describing 'time' as a time relative to 'now'. | |
* <p> | |
* Time spans in the past are formatted like "42 minutes ago". Time spans in | |
* the future are formatted like "in 42 minutes". | |
* <p> | |
* Can use {@link #FORMAT_ABBREV_RELATIVE} flag to use abbreviated relative | |
* times, like "42 mins ago". | |
* | |
* @param time the time to describe, in milliseconds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns a string describing a day relative to the current day. For example if the day is | |
* today this function returns "Today", if the day was a week ago it returns "7 days ago", and | |
* if the day is in 2 weeks it returns "in 14 days". | |
* | |
* @param r the resources | |
* @param day the relative day to describe in UTC milliseconds | |
* @param today the current time in UTC milliseconds | |
*/ | |
private static final String getRelativeDayString(Resources r, long day, long today) { |
OlderNewer