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:ai.api.http.HttpClient.java

public void addFilePart(@NonNull final String paramName, @NonNull final String fileName,
        @NonNull final InputStream data) throws IOException {
    os.write((delimiter + boundary + "\r\n").getBytes());
    os.write(("Content-Disposition: form-data; name=\"" + paramName + "\"; filename=\"" + fileName + "\"\r\n")
            .getBytes());/*  w  w  w.  ja va  2s. co  m*/
    os.write(("Content-Type: audio/wav\r\n").getBytes());
    //os.write( ("Content-Transfer-Encoding: binary\r\n"  ).getBytes());
    os.write("\r\n".getBytes());

    Log.v(TAG, "Sound write start");

    FileOutputStream outputStream = null;

    if (writeSoundLog) {
        final File cacheDir = new File(android.os.Environment.getExternalStorageDirectory(), "sound_log");
        if (!cacheDir.exists()) {
            cacheDir.mkdirs();
        }
        Log.d(TAG, cacheDir.getAbsolutePath());

        final File soundFile = new File(cacheDir, "log.wav");
        outputStream = new FileOutputStream(soundFile, false);
    }

    //TODO remove magic number
    final int bufferSize = 4096;
    final byte[] buffer = new byte[bufferSize];

    int bytesActuallyRead;

    bytesActuallyRead = data.read(buffer, 0, bufferSize);
    Log.v(TAG, "Bytes read: " + bytesActuallyRead);

    while (bytesActuallyRead >= 0) {
        if (bytesActuallyRead > 0) {
            os.write(buffer, 0, bytesActuallyRead);

            if (writeSoundLog) {
                outputStream.write(buffer, 0, bytesActuallyRead);
            }
        }
        bytesActuallyRead = data.read(buffer, 0, bufferSize);
        Log.v(TAG, "Bytes read: " + bytesActuallyRead);
    }

    if (writeSoundLog) {
        outputStream.close();
    }

    Log.v(TAG, "Sound write finished");

    os.write("\r\n".getBytes());
}

From source file:com.cafbit.multicasttest.NetThread.java

/**
 * The main network loop.  Multicast DNS packets are received,
 * processed, and sent to the UI.// w  w  w  . java 2s . c  o  m
 * 
 * This loop may be interrupted by closing the multicastSocket,
 * at which time any commands in the commandQueue will be
 * processed.
 */
@Override
public void run() {
    Log.v(TAG, "starting network thread");

    localAddresses = NetUtil.getLocalAddresses();
    multicastLock = null;

    // initialize the network
    try {
        networkInterface = netUtil.getFirstWifiOrEthernetInterface();
        if (networkInterface == null) {
            throw new IOException("Your WiFi is not enabled.");
        }
        groupAddress = InetAddress.getByAddress(MDNS_ADDR);

        WifiManager wm = (WifiManager) MulticastTestActivity.mThis
                .getSystemService(MulticastTestActivity.mThis.getApplicationContext().WIFI_SERVICE);
        WifiManager.MulticastLock multicastLock = wm.createMulticastLock("mydebuginfo");
        multicastLock.acquire();

        openSocket();
    } catch (IOException e1) {
        Log.i(TAG, "IOException : " + e1.getMessage());
        return;
    }

    mReceivedTask = new ReceivedTask();
    mReceivedTask.execute("");
    try {
        mReceivedTask.get();
    } catch (InterruptedException e1) {

    } catch (ExecutionException e1) {
    }

}

From source file:org.openschedule.api.impl.EventTemplate.java

public List<Comment> getEventComments(String shortName) {
    Log.v(TAG, "getEventComments : enter");

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "getEventComments : shortName=" + shortName);
    }//from w  ww. j  a  v  a 2  s. c o m

    Log.v(TAG, "getEventComments : exit");
    return restTemplate.getForObject(buildUri("public/" + shortName + "/comments"), CommentList.class);
}

From source file:com.parking.auth.RegisterUserActivity.java

@Override
public void notifyResult(boolean result) {
    if (result == true) {
        Log.v(TAG, "User registration successful.");
        /** //  ww w .  j  av  a  2  s .  c  o m
         * Send the result back. This way using the result, we can kill the 
         * previous activity on the stack.
         */
        if (getParent() == null) {
            setResult(Activity.RESULT_OK, this.getIntent());
        } else {
            getParent().setResult(Activity.RESULT_OK, this.getIntent());
        }
        finish();
    } else {
        clearButton.performClick();
    }

}

From source file:com.example.yudiandrean.socioblood.Twitter.TwitterActivity.java

public void getTwitter() {
    ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

    if (networkInfo != null && networkInfo.isConnected()) {
        new DownloadTwitterTask().execute(ScreenName);
    } else {/*from   ww  w. j  a  v  a  2s .  c  o m*/
        Log.v(LOG_TAG, "No network connection available.");
    }
}

From source file:com.cbtec.eliademy.GCMIntentService.java

@Override
protected void onMessage(Context context, Intent intent) {
    Bundle extras = intent.getExtras();// w w  w .  j  a  va  2s .  c  o  m
    Log.d(TAG, "Received message" + extras.toString());
    if (extras != null) {
        try {
            JSONObject json;
            json = new JSONObject().put("event", "notifications");
            json.put("notifications", extras.getString("notifications"));

            Log.v(TAG, json.toString());
            if (GCMPlugin.isActive()) {
                // TODO: Find better way
                JSONObject msgobj = new JSONObject(extras.getString("notifications"));
                String msg = msgobj.getString("author") + " " + msgobj.getString("content") + " for course "
                        + msgobj.getString("coursename");
                generateNotification(context, msg);
                GCMPlugin.sendJavascript(json);
            } else {
                // form message
                JSONObject msgobj = new JSONObject(extras.getString("notifications"));
                String msg = msgobj.getString("author") + " " + msgobj.getString("content") + " for course "
                        + msgobj.getString("coursename");
                generateNotification(context, msg);
            }
        } catch (JSONException e) {
            Log.e(TAG, "JSON exception" + e.getMessage());
        }
    }
}

From source file:com.github.hobbe.android.openkarotz.fragment.ColorFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    Log.v(LOG_TAG, "onCreate, bundle: " + savedInstanceState);
    super.onCreate(savedInstanceState);

    // Load colors from asset
    colors = loadColorsFromAsset();//from www  .jav a  2 s.c om
}

From source file:pro.dbro.bart.RequestTask.java

@Override
protected String doInBackground(String... uri) {
    if (BART.USE_LOCAL_RESPONSES) {
        Log.d("RequestTask", "Using local responses");
        try {/*from   ww  w .j a v a  2  s.  c  om*/
            String filename = null;
            if (request.compareTo("etd") == 0)
                filename = "problem_etd.aspx.xml";
            else
                filename = "problem_sched.aspx.xml";

            BufferedReader r = new BufferedReader(
                    new InputStreamReader((TheActivity.c.getAssets().open(filename))));
            StringBuilder total = new StringBuilder();
            String line;
            while ((line = r.readLine()) != null) {
                total.append(line);
            }
            return total.toString();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    HttpClient httpclient = new DefaultHttpClient();
    HttpResponse response;
    String responseString = null;
    try {
        String url = uri[0];
        response = httpclient.execute(new HttpGet(uri[0]));
        StatusLine statusLine = response.getStatusLine();
        if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            response.getEntity().writeTo(out);
            out.close();
            responseString = out.toString();
        } else {
            //Closes the connection.
            response.getEntity().getContent().close();
            throw new IOException(statusLine.getReasonPhrase());
        }
    } catch (ClientProtocolException e) {
        //TODO Handle problems..
        return "error";
    } catch (IOException e) {
        Log.v("RequestTask", e.toString());
        return "error";
        //TODO Handle problems..
    }
    return responseString;
}

From source file:com.funzio.pure2D.atlas.JsonAtlas.java

/**
 * Load from assets/*from   ww w .  j a  v a  2 s . c  om*/
 * 
 * @param assets
 * @param filePath
 * @param scale
 * @throws IOException
 * @throws JSONException
 */
public void load(final AssetManager assets, final String filePath, final float scale)
        throws IOException, JSONException {
    Log.v(TAG, "load(): " + filePath);

    if (assets == null) {
        load(new FileInputStream(new File(filePath)), scale);
    } else {
        load(assets.open(filePath), scale);
    }

    // listener
    if (mListener != null) {
        mListener.onAtlasLoad(JsonAtlas.this);
    }
}

From source file:com.goliathonline.android.kegbot.io.RemoteDrinksHandler.java

/** {@inheritDoc} */
@Override//  w w  w .ja  v a  2  s  . c  om
public ArrayList<ContentProviderOperation> parse(JSONObject parser, ContentResolver resolver)
        throws JSONException, IOException {
    final ArrayList<ContentProviderOperation> batch = Lists.newArrayList();

    // Walk document, parsing any incoming entries
    int drink_id = 0;
    JSONObject result = parser.getJSONObject("result");
    JSONArray drinks = result.getJSONArray("drinks");
    JSONObject drink;
    for (int i = 0; i < drinks.length(); i++) {
        if (drink_id == 0) { // && ENTRY.equals(parser.getName()
            // Process single spreadsheet row at a time
            drink = drinks.getJSONObject(i);
            final String drinkId = sanitizeId(drink.getString("id"));
            final Uri drinkUri = Drinks.buildDrinkUri(drinkId);

            // Check for existing details, only update when changed
            final ContentValues values = queryDrinkDetails(drinkUri, resolver);
            final long localUpdated = values.getAsLong(SyncColumns.UPDATED);
            final long serverUpdated = 500; //entry.getUpdated();
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "found drink " + drinkId);
                Log.v(TAG, "found localUpdated=" + localUpdated + ", server=" + serverUpdated);
            }
            if (localUpdated != KegbotContract.UPDATED_NEVER)
                continue;

            final Uri drinkKegUri = Drinks.buildKegUri(drinkId);
            final Uri drinkUserUri = Drinks.buildUserUri(drinkId);

            // Clear any existing values for this session, treating the
            // incoming details as authoritative.
            batch.add(ContentProviderOperation.newDelete(drinkUri).build());
            batch.add(ContentProviderOperation.newDelete(drinkKegUri).build());

            final ContentProviderOperation.Builder builder = ContentProviderOperation
                    .newInsert(Drinks.CONTENT_URI);

            builder.withValue(SyncColumns.UPDATED, serverUpdated);
            builder.withValue(Drinks.DRINK_ID, drinkId);

            // Inherit starred value from previous row
            if (values.containsKey(Drinks.DRINK_STARRED)) {
                builder.withValue(Drinks.DRINK_STARRED, values.getAsInteger(Drinks.DRINK_STARRED));
            }

            if (drink.has("session_id"))
                builder.withValue(Drinks.SESSION_ID, drink.getInt("session_id"));
            if (drink.has("status"))
                builder.withValue(Drinks.STATUS, drink.getString("status"));
            if (drink.has("user_id"))
                builder.withValue(Drinks.USER_ID, drink.getString("user_id"));
            if (drink.has("keg_id"))
                builder.withValue(Drinks.KEG_ID, drink.getInt("keg_id"));
            if (drink.has("volume_ml"))
                builder.withValue(Drinks.VOLUME, drink.getDouble("volume_ml"));
            if (drink.has("pour_time"))
                builder.withValue(Drinks.POUR_TIME, drink.getString("pour_time"));

            // Normal session details ready, write to provider
            batch.add(builder.build());

            // Assign kegs
            final int kegId = drink.getInt("keg_id");
            batch.add(ContentProviderOperation.newInsert(drinkKegUri).withValue(DrinksKeg.DRINK_ID, drinkId)
                    .withValue(DrinksKeg.KEG_ID, kegId).build());

            // Assign users
            if (drink.has("user_id")) {
                final String userId = drink.getString("user_id");
                batch.add(ContentProviderOperation.newInsert(drinkUserUri)
                        .withValue(DrinksUser.DRINK_ID, drinkId).withValue(DrinksUser.USER_ID, userId).build());
            }
        }
    }

    return batch;
}