Example usage for android.util Log v

List of usage examples for android.util Log v

Introduction

In this page you can find the example usage for android.util Log v.

Prototype

public static int v(String tag, String msg) 

Source Link

Document

Send a #VERBOSE log message.

Usage

From source file:net.heroicefforts.viable.android.dao.Issue.java

/**
 * Instantiate the issue state based upon the JIRA JSON format.
 * //from   w  ww . ja v  a  2  s .  c o m
 * @param obj JIRA JSON issue object 
 * @throws JSONException if there's an error parsing the JSON.
 */
public Issue(String json) throws JSONException {
    if (Config.LOGV)
        Log.v(TAG, "Parsing issue JSON:  " + json);
    JSONObject issueObj = new JSONObject(json);
    issueId = issueObj.getString("issueId");
    type = issueObj.getString("type");
    if (issueObj.has("priority"))
        priority = issueObj.getString("priority");
    state = issueObj.getString("state");
    appName = issueObj.getString("appName");
    summary = issueObj.getString("summary");
    if (issueObj.has("votes"))
        votes = issueObj.getLong("votes");
    if (issueObj.has("description"))
        description = issueObj.getString("description");
    if (issueObj.has("affectedVersions")) {
        JSONArray affVers = issueObj.getJSONArray("affectedVersions");
        affectedVersions = new String[affVers.length()];
        for (int i = 0; i < affVers.length(); i++)
            affectedVersions[i] = affVers.getString(i);
    }
    if (issueObj.has("hash"))
        hash = issueObj.getString("hash");
    if (issueObj.has("stacktrace"))
        stacktrace = issueObj.getString("stacktrace");
    SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    fmt.setLenient(true);
    try {
        createDate = fmt.parse(issueObj.getString("createDate"));
        modifiedDate = fmt.parse(issueObj.getString("modifiedDate"));
    } catch (ParseException e) {
        Log.e(TAG, "Error parsing JSON dates.", e);
        throw new JSONException("Error parsing JSON dates.");
    }
}

From source file:com.bez4pieci.cookies.Cookies.java

public void setCookie(String action, JSONArray args, CallbackContext callbackContext) {
    Log.v(TAG, "Setting cookie");
    if (args.length() == 0) {
        System.err.println("Exception: No Arguments passed");
    } else {/*from  w  w  w . jav  a 2  s. c  o m*/
        try {
            JSONObject options = args.getJSONObject(0);

            String protocol = DEFAULT_PROTOCOL;
            String host = null;
            int port = DEFAULT_PORT;
            String path = null;

            // Set the protocol
            if (options.has("protocol")) {
                protocol = options.getString("protocol");
            }

            // Set the domain/host
            if (options.has("domain")) {
                host = options.getString("domain");
            } else if (options.has("host")) {
                host = options.getString("host");
            }

            // Set the port
            if (options.has("port")) {
                port = options.getInt("port");
            }

            // Set the file/path
            if (options.has("file")) {
                path = options.getString("file");
            } else if (options.has("path")) {
                path = options.getString("path");
            }

            URL url = new URL(protocol, host, port, path);

            CookieManager.getInstance().setCookie(url.toString(), options.optString("value"));
        } catch (JSONException e) {
            Log.e(TAG, "Exception while setting cookie", e);
        } catch (MalformedURLException e) {
            Log.e(TAG, "Exception while setting cookie", e);
        }
    }
}

From source file:com.facebook.unity.FB.java

@UnityCallable
public static void Init(final String params_str) {
    Log.v(TAG, "Init(" + params_str + ")");
    UnityParams unity_params = UnityParams.parse(params_str, "couldn't parse init params: " + params_str);
    final String appID;
    if (unity_params.hasString("appId")) {
        appID = unity_params.getString("appId");
    } else {//from  w w  w. j a v  a 2  s .c o  m
        appID = Utility.getMetadataApplicationId(getUnityActivity());
    }

    FacebookSdk.setApplicationId(appID);
    FacebookSdk.sdkInitialize(FB.getUnityActivity(), new FacebookSdk.InitializeCallback() {
        @Override
        public void onInitialized() {
            final UnityMessage unityMessage = new UnityMessage("OnInitComplete");
            // If we have a cached access token send it back as well
            AccessToken token = AccessToken.getCurrentAccessToken();
            if (token != null) {
                FBLogin.addLoginParametersToMessage(unityMessage, token, null);
            } else {
                unityMessage.put("key_hash", FB.getKeyHash());
            }

            FB.ActivateApp(appID);

            unityMessage.send();
        }
    });
}

From source file:com.pindroid.client.NetworkUtilities.java

/**
 * Attempts to authenticate to Pinboard using a legacy Pinboard account.
 * //w  ww .  j  a  v  a 2 s.  c  o m
 * @param username The user's username.
 * @param password The user's password.
 * @param handler The hander instance from the calling UI thread.
 * @param context The context of the calling Activity.
 * @return The boolean result indicating whether the user was
 *         successfully authenticated.
 */
public static boolean pinboardAuthenticate(String username, String password) {
    final HttpResponse resp;

    Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME);
    builder.authority(PINBOARD_AUTHORITY);
    builder.appendEncodedPath("v1/posts/update");
    Uri uri = builder.build();

    HttpGet request = new HttpGet(String.valueOf(uri));

    DefaultHttpClient client = (DefaultHttpClient) HttpClientFactory.getThreadSafeClient();

    CredentialsProvider provider = client.getCredentialsProvider();
    Credentials credentials = new UsernamePasswordCredentials(username, password);
    provider.setCredentials(SCOPE, credentials);

    try {
        resp = client.execute(request);
        if (resp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "Successful authentication");
            }
            return true;
        } else {
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "Error authenticating" + resp.getStatusLine());
            }
            return false;
        }
    } catch (final IOException e) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "IOException when getting authtoken", e);
        }
        return false;
    } finally {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "getAuthtoken completing");
        }
    }
}

From source file:com.finlay.geomonsters.MyIOCallback.java

@Override
public void onError(SocketIOException arg0) {
    Log.v(TAG, "onError " + arg0.getMessage());
    arg0.printStackTrace();/*from   w ww .  j a v a2 s  .c  om*/

    if (arg0.getMessage().equals("Error while handshaking"))
        _mainActivity.appendMessage("Could not connect to server.");
}

From source file:at.bitfire.davdroid.URIUtils.java

/**
 * Parse a received absolute/relative URL and generate a normalized URI that can be compared.
 * @param original       URI to be parsed, may be absolute or relative
  * @param mustBePath    true if it's known that original is a path (may contain ":") and not an URI, i.e. ":" is not the scheme separator
 * @return             normalized URI//from  www .  j  a v  a2  s .c om
 * @throws URISyntaxException
 */
public static URI parseURI(String original, boolean mustBePath) throws URISyntaxException {
    if (mustBePath) {
        // may contain ":"
        // case 1: "my:file"        won't be parsed by URI correctly because it would consider "my" as URI scheme
        // case 2: "path/my:file"   will be parsed by URI correctly
        // case 3: "my:path/file"   won't be parsed by URI correctly because it would consider "my" as URI scheme
        int idxSlash = original.indexOf('/'), idxColon = original.indexOf(':');
        if (idxColon != -1) {
            // colon present
            if ((idxSlash != -1) && idxSlash < idxColon) // There's a slash, and it's before the colon  everything OK
                ;
            else // No slash before the colon; we have to put it there
                original = "./" + original;
        }
    }

    // escape some common invalid characters  servers keep sending unescaped crap like "my calendar.ics" or "{guid}.vcf"
    // this is only a hack, because for instance, "[" may be valid in URLs (IPv6 literal in host name)
    String repaired = original.replaceAll(" ", "%20").replaceAll("\\{", "%7B").replaceAll("\\}", "%7D");
    if (!repaired.equals(original))
        Log.w(TAG, "Repaired invalid URL: " + original + " -> " + repaired);

    URI uri = new URI(repaired);
    URI normalized = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), uri.getQuery(),
            uri.getFragment());
    Log.v(TAG, "Normalized URL " + original + " -> " + normalized.toASCIIString());
    return normalized;
}

From source file:com.memetro.android.notifications.NotificationUtils.java

/**
 * Gets the current registration id for application on GCM service.
 * <p>/*from  ww w  .jav a2 s  . c  o  m*/
 * If result is empty, the registration has failed.
 *
 * @return registration id, or empty string if the registration is not
 * complete.
 */
public static String getRegistrationId(Context context) {
    final SharedPreferences prefs = getGCMPreferences(context);
    String registrationId = prefs.getString(PROPERTY_REG_ID, "");
    if (registrationId.length() == 0) {
        Log.v(TAG, "Registration not found.");
        return "";
    }
    // check if app was updated; if so, it must clear registration id to
    // avoid a race condition if GCM sends a message
    int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
    int currentVersion = getAppVersion(context);
    if (registeredVersion != currentVersion || isRegistrationExpired(context)) {
        Log.v(TAG, "App version changed or registration expired.");
        return "";
    }
    return registrationId;
}

From source file:com.rumblefish.friendlymusic.api.WebRequest.java

public static String webRequest(URLRequest request) {
    HttpPost httpPost = null;/*from   ww  w.  ja  va 2s  . c o  m*/
    HttpGet httpGet = null;
    if (request.m_nameValuePairs != null) {
        httpPost = new HttpPost(request.m_serverURL);
        try {
            httpPost.setEntity(new UrlEncodedFormEntity(request.m_nameValuePairs));
        } catch (Exception e) {
            return null;
        }
    } else {
        httpGet = new HttpGet(request.m_serverURL);
        Log.v(LOGTAG, request.m_serverURL);
    }

    HttpClient client = getNewHttpClient(request.m_timelimit);

    StringBuilder builder = new StringBuilder();

    try {
        HttpResponse response;
        if (request.m_nameValuePairs != null)
            response = client.execute(httpPost);
        else
            response = client.execute(httpGet);

        StatusLine statusLine = response.getStatusLine();
        int statusCode = statusLine.getStatusCode();
        if (statusCode == 200) {
            HttpEntity entity = response.getEntity();
            InputStream content = entity.getContent();
            BufferedReader reader = new BufferedReader(new InputStreamReader(content));
            String line;
            while ((line = reader.readLine()) != null) {
                builder.append(line);
            }
            try {
                content.close();
            } catch (IOException e) {

            }
        } else {
            Log.e("WebRequest", "Failed to download file");
            return null;
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        client.getConnectionManager().closeExpiredConnections();
        client.getConnectionManager().closeIdleConnections(0, TimeUnit.NANOSECONDS);
    }

    String resultString = builder.toString();
    try {
        if (resultString == null || resultString.length() == 0) {
            return null;
        }
        return resultString;
    } catch (Exception e) {
        return null;
    }
}

From source file:no.uka.findmyapp.android.rest.client.RestProcessor.java

/**
 * Call rest./*w  ww. j a  v a 2 s. c o  m*/
 *
 * @param serviceModel the service model
 * @throws HttpException 
 * @throws HTTPStatusException 
 */
public void callRest(ServiceModel serviceModel, String userToken) {
    Log.v(debug, "Inside callRest");
    try {
        switch (serviceModel.getHttpType()) {
        case GET:
            Serializable returnedObject;
            returnedObject = executeAndParse(serviceModel, userToken);
            saveAndReturnData(serviceModel, returnedObject);
            break;
        case POST:
            Serializable postReturnedObject = executeAndParse(serviceModel, userToken);
            saveAndReturnData(serviceModel, postReturnedObject);
            break;
        }
    } catch (HTTPStatusException e) {
        sendIntentBroadcast(IntentMessages.BROADCAST_HTTP_STATUS_EXCEPTION, e);
    }
}