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:com.clearcenter.mobile_demo.mdAuthenticator.java

public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
        String[] requiredFeatures, Bundle options) {
    Log.v(TAG, "addAccount()");
    final Intent intent = new Intent(ctx, mdAuthenticatorActivity.class);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}

From source file:Main.java

private static void post(String endpoint, Map<String, String> params) throws IOException {

    URL url;/*from   w w  w  .j ava 2s.c  om*/
    try {
        url = new URL(endpoint);
    } catch (MalformedURLException e) {
        throw new IllegalArgumentException("invalid url: " + endpoint);
    }
    StringBuilder bodyBuilder = new StringBuilder();
    Iterator<Map.Entry<String, String>> iterator = params.entrySet().iterator();
    // constructs the POST body using the parameters
    while (iterator.hasNext()) {
        Map.Entry<String, String> param = iterator.next();
        bodyBuilder.append(param.getKey()).append('=').append(param.getValue());
        if (iterator.hasNext()) {
            bodyBuilder.append('&');
        }
    }
    String body = bodyBuilder.toString();
    Log.v(TAG, "Posting '" + body + "' to " + url);
    byte[] bytes = body.getBytes();
    HttpURLConnection conn = null;
    try {
        Log.e("URL", "> " + url);
        conn = (HttpURLConnection) url.openConnection();
        conn.setDoOutput(true);
        conn.setUseCaches(false);
        conn.setFixedLengthStreamingMode(bytes.length);
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
        // post the request
        OutputStream out = conn.getOutputStream();
        out.write(bytes);
        out.close();
        // handle the response
        int status = conn.getResponseCode();
        if (status != 200) {
            throw new IOException("Post failed with error code " + status);
        }
    } finally {
        if (conn != null) {
            conn.disconnect();
        }
    }
}

From source file:gravity.android.discovery.DiscoveryServer.java

public void run() {
    Log.v("DISCOVERY_SERVER", "SERVER STARTED");

    DatagramSocket serverSocket = null;

    try {/*from  w ww  . j  a  v  a2 s. c om*/
        serverSocket = new DatagramSocket(port);
        byte[] receiveData;
        byte[] sendData;

        while (this.isInterrupted() == false) {
            receiveData = new byte[128];
            sendData = new byte[128];

            try {
                Log.v("DISCOVERY_SERVER", "LISTENING");
                DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
                serverSocket.receive(receivePacket);
                String sentence = new String(receivePacket.getData());

                if (sentence != null)
                    Log.v("DISCOVERY_SERVER",
                            "RECEIVED: " + sentence.substring(0, receivePacket.getLength()).trim());

                if (sentence != null && sentence.substring(0, receivePacket.getLength()).trim().equals(token)) {
                    Log.v("DISCOVERY_SERVER", "SEND '" + nome + "' to "
                            + receivePacket.getAddress().getHostAddress() + ":" + receivePacket.getPort());
                    JSONObject sendDataJson = new JSONObject();
                    sendDataJson.accumulate("name", nome);
                    sendDataJson.accumulate("port_to_share", port_to_share);

                    //sendData = (nome + "," + port_to_share).getBytes();
                    sendData = sendDataJson.toString().getBytes(); //Prakash: converts the data to json objects to avoid troubles

                    DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length,
                            receivePacket.getAddress(), receivePacket.getPort());
                    serverSocket.send(sendPacket);
                }

            } catch (Exception ex) {
                ex.printStackTrace();
                Log.e("DISCOVERY_SERVER", ex.toString());
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        Log.e("DISCOVERY_SERVER", e.toString());
    } finally {
        try {
            if (serverSocket != null)
                serverSocket.close();
        } catch (Exception ex) {
        }
    }

}

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

/**
 * Instantiates a new rest processor.//  w  w  w.j  a  v a 2  s  .  c o  m
 *
 * @param context the context
 */
public RestProcessor(Context context, Credentials credentials) {
    Log.v(debug, "Inside RestProcessor creator");

    mRestMethod = new RestMethod(credentials);
    mGson = new GsonBuilder().create();
    mContext = context;
}

From source file:org.bishoph.oxdemo.util.CreateTaskAction.java

@Override
protected JSONObject doInBackground(Object... params) {
    try {//from   w w w  .  ja v a 2  s.c  o  m
        String uri = (String) params[0];
        String title = (String) params[1];
        if (title == null && folder_id > 0) {
            Log.v("OXDemo", "Either title or folder_id missing. Done nothing!");
            return null;
        }

        Log.v("OXDemo", "Attempting to create task " + title + " on " + uri);

        JSONObject jsonobject = new JSONObject();
        jsonobject.put("folder_id", folder_id);
        jsonobject.put("title", title);
        jsonobject.put("status", 1);
        jsonobject.put("priority", 0);
        jsonobject.put("percent_completed", 0);
        jsonobject.put("recurrence_type", 0);
        jsonobject.put("private_flag", false);
        jsonobject.put("notification", false);

        Log.v("OXDemo", "Body = " + jsonobject.toString());
        HttpPut httpput = new HttpPut(uri);
        StringEntity stringentity = new StringEntity(jsonobject.toString(), HTTP.UTF_8);
        stringentity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json;charset=UTF-8"));
        httpput.setHeader("Accept", "application/json, text/javascript");
        httpput.setHeader("Content-type", "application/json");
        httpput.setEntity(stringentity);

        HttpResponse response = httpclient.execute(httpput, localcontext);
        Log.v("OXDemo", "Created task " + title);
        HttpEntity entity = response.getEntity();
        String result = EntityUtils.toString(entity);
        Log.d("OXDemo", "<<<<<<<\n" + result + "\n\n");
        JSONObject jsonObj = new JSONObject(result);
        jsonObj.put("title", title);
        return jsonObj;
    } catch (JSONException e) {
        Log.e("OXDemo", e.getMessage());
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.daiv.android.twitter.services.TrimDataService.java

@Override
public void onHandleIntent(Intent intent) {
    Log.v("trimming_database", "trimming database from service");
    IOUtils.trimDatabase(getApplicationContext(), 1); // trims first account
    IOUtils.trimDatabase(getApplicationContext(), 2); // trims second account

    getContentResolver().notifyChange(HomeContentProvider.CONTENT_URI, null);

    setNextTrim(this);

    //checkForUpdate();
}

From source file:org.bishoph.oxdemo.util.DeleteTask.java

@Override
protected JSONObject doInBackground(Object... params) {
    try {/*from  w  w  w . j av  a2  s  .co m*/
        String uri = (String) params[0];
        int object_id = (Integer) params[1];
        Log.v("OXDemo", "Attempting to delete task " + object_id + " in folder " + folder_id + " on " + uri);

        // [{"id":25,"folder":27}]
        JSONObject jsonobject = new JSONObject();
        jsonobject.put("id", object_id);
        jsonobject.put("folder", folder_id);
        JSONArray jsonarray = new JSONArray();
        jsonarray.put(jsonobject);

        HttpPut httput = new HttpPut(uri);
        StringEntity stringentity = new StringEntity(jsonarray.toString());
        Log.v("OXDemo", "JSON ? " + stringentity);
        stringentity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json; charset=UTF-8")); // 
        httput.setHeader("Accept", "application/json, text/javascript");
        httput.setHeader("Content-type", "application/json");
        httput.setEntity(stringentity);

        HttpResponse response = httpclient.execute(httput, localcontext);
        Log.v("OXDemo", "Delete task " + object_id);
        HttpEntity entity = response.getEntity();
        String result = EntityUtils.toString(entity);
        Log.d("OXDemo", "<<<<<<<\n" + result + "\n\n");
        JSONObject jsonObj = new JSONObject(result);
        return jsonObj;
    } catch (JSONException e) {
        Log.e("OXDemo", e.getMessage());
    } catch (ClientProtocolException e) {
        Log.e("OXDemo", e.getMessage());
    } catch (IOException e) {
        Log.e("OXDemo", e.getMessage());
    }
    return null;
}

From source file:com.tarsoft.openlibra.OpenLibraClient.java

public List<Book> getBooks(Criteria criteria) throws JSONException, MalformedURLException, IOException {

    this.criteria = criteria;

    HttpClient httpClient = new DefaultHttpClient();

    String getURL = getURLOpenLibra();

    Log.v(TAG, "URL: " + getURL);

    URI uri;//from   ww w .j av a  2  s. c  om
    String data = null;
    try {
        uri = new URI(getURL);
        HttpGet method = new HttpGet(uri);
        HttpResponse response = httpClient.execute(method);

        HttpEntity resEntity = response.getEntity();

        //if exists, get it
        if (resEntity != null) {
            data = EntityUtils.toString(resEntity, HTTP.UTF_8);
        }

    } catch (Exception e) {
        e.printStackTrace();
        Log.v(TAG, "Error: " + e.getMessage() + " - " + e.getLocalizedMessage());
    }

    if (data != null) {
        //Delete initial "(" and final ");"
        data = data.substring(1, data.length() - 2);

        return parseData(data);
    } else {
        return null;
    }

}

From source file:com.varoid.exoplanethunter.JSONParser.java

public String getJSON(String obj, String json_text) {
    try {// ww w . j  a  va2s .c  o m
        json = new JSONObject(json_text);
        try {

            return json.getString(obj);
        } catch (Exception e) {
            Log.v("error3", e.getMessage().toString());
            return "";
        }
    } catch (Exception e) {
        Log.v("error4", e.getMessage().toString());
        return "";
    }

}

From source file:io.github.acashjos.anarch.RegexValueMatchBuilder.java

/**
 * Internal function// ww w .  ja v  a 2s  .c om
 * Processes response body according to the matchbuilder specifications and returns JSONObject
 * @param responseText String on which the operations are to be conducted
 * @return JSONObject Object with all the extracted properties
 */
@Override
protected JSONObject processResponseText(String responseText) {
    JSONObject output = new JSONObject();

    for (PatternBlueprint test : patternSet) {
        Pattern p = Pattern.compile(test.pattern);
        Matcher m = p.matcher(responseText);

        JSONArray arr = new JSONArray();
        while (m.find()) {
            Log.v("debug", "find(): " + m.group());
            JSONObject single = test.once ? output : new JSONObject();

            //insers keys from mainTest
            for (Map.Entry<String, Integer> outkey : test.outputKeySet.entrySet()) {

                Log.v("debug", "outputkeyset: " + outkey.getKey());
                try {
                    single.put(outkey.getKey(), m.group(outkey.getValue()));
                } catch (JSONException e) {
                    e.printStackTrace();
                    continue;
                }
            }

            for (PatternBlueprint subtest : test.subPatternSet) {
                String patern = test.pattern;
                for (int i = 1; i <= m.groupCount(); ++i) {
                    patern = patern.replace("%" + i, m.group(i));
                }
                Pattern p2 = Pattern.compile(patern);
                Matcher m2 = p2.matcher(m.group(subtest.source_group));
                if (m2.find())
                    //insert keys from subtest
                    for (Map.Entry<String, Integer> outkey : subtest.outputKeySet.entrySet())
                        try {
                            single.put(outkey.getKey(), m2.group(outkey.getValue()));
                        } catch (JSONException e) {
                            e.printStackTrace();
                            continue;
                        }
            }
            if (!test.once) {
                arr.put(single);
            }

        }
        if (!test.once)
            try {
                output.put(test.id, arr);
            } catch (JSONException e) {
                continue;
            }

    }
    return output;
}