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.finalproject.deliveronthego.SignUpDriver.java

public void getRegId() {
    new AsyncTask<Void, Void, String>() {
        @Override/*from  w  ww .  ja v  a2  s.  c o m*/
        protected String doInBackground(Void... params) {
            String msg = "";
            try {
                if (gcm == null) {
                    gcm = GoogleCloudMessaging.getInstance(getApplicationContext());
                }
                regid = gcm.register(projectNumber);
                msg = "Device registered, registration ID=" + regid;
                Log.i("GCM", msg);

            } catch (IOException ex) {
                msg = "Error :" + ex.getMessage();

            }
            return msg;
        }

        @Override
        protected void onPostExecute(String msg) {
            Log.v("reg id", msg);
            new MyDriverSignup(getBaseContext()).execute(firstName.getText().toString(),
                    lastName.getText().toString(), password.getText().toString(),
                    driverLicense.getText().toString(), emailid.getText().toString(),
                    phoneNumber.getText().toString(), msg);

        }
    }.execute(null, null, null);
}

From source file:com.mb.kids_mind.AbstractGetNameTask.java

/**
 * Contacts the user info server to get the profile of the user and extracts the first name
 * of the user from the profile. In order to authenticate with the user info server the method
 * first fetches an access token from Google Play services.
 * @throws IOException if communication with user info server failed.
 * @throws JSONException if the response from the server could not be parsed.
 *//*from   w ww  .  j  a va 2s  . com*/
private void fetchNameFromProfileServer() throws IOException, JSONException {
    String token = fetchToken();
    Log.v(TAG, "token" + token);
    if (token == null) {
        // error has already been handled in fetchToken()
        return;
    }
    URL url = new URL("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + token);
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    int sc = con.getResponseCode();
    if (sc == 200) {
        InputStream is = con.getInputStream();
        String name = getFirstName(readResponse(is));
        // mActivity.show("Hello " + name + "!");
        is.close();
        return;
    } else if (sc == 401) {
        GoogleAuthUtil.invalidateToken(mActivity, token);
        onError("Server auth error, please try again.", null);
        Log.i(TAG, "Server auth error: " + readResponse(con.getErrorStream()));
        return;
    } else {
        onError("Server returned the following error code: " + sc, null);
        return;
    }
}

From source file:com.example.run_tracker.MyRunsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Log.v(TAG, "onActivityCreated");

    super.onActivityCreated(savedInstanceState);

    if (savedInstanceState != null) {
        mTracks = savedInstanceState.getParcelableArrayList("tracklist");
    }//from   ww w .ja  v  a  2s.  c  om
}

From source file:com.wso2.mobile.mdm.api.PhoneState.java

/**
*Returns the available amount of memory in the device
*//*ww  w. ja  v a2s.c  om*/
public String getAvailableMemory() {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(context.ACTIVITY_SERVICE);
    MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
    activityManager.getMemoryInfo(memoryInfo);
    Log.v("Available Memory", memoryInfo.availMem + "");
    String availMemory = memoryInfo.availMem + "";
    return availMemory;
}

From source file:com.nbos.phonebook.sync.client.Net.java

/**
 * Connects to the Voiper server, authenticates the provided username and
 * password./*from  w  ww  .j a  v a2s.co 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 boolean The boolean result indicating whether the user was
 *         successfully authenticated.
 * @throws IOException 
 * @throws JSONException 
 * @throws ClientProtocolException 
 */
public static boolean authenticate(String username, String password, String ph, Handler handler,
        final Context context) {
    Log.i(tag, "Authenticate");

    final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair(PARAM_USERNAME, username));
    params.add(new BasicNameValuePair(PARAM_PASSWORD, password));
    params.add(new BasicNameValuePair(PARAM_PHONE_NUMBER, ph));
    try {
        final HttpResponse response = new Cloud(null, username, password).postHttp(AUTH_URI, params);
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            Log.i(tag, "Successful authentication");
            Log.i(tag, "data: " + EntityUtils.toString(response.getEntity()));
            sendResult(true, handler, context, null);
            return true;
        } else {
            Log.v(tag, "Error authenticating: " + response.getStatusLine());
            sendResult(false, handler, context, "Error authenticating: " + response.getStatusLine());
            return false;
        }

    } catch (Exception e) {
        e.printStackTrace();
        Log.v(tag, "Exception: ", e);
        // }
        sendResult(false, handler, context, e.getMessage());
        return false;
    }
}

From source file:com.funzio.pure2D.particles.nova.NovaLoader.java

/**
 * Load a specific Nova file, synchronously
 * /*from  www.  j a  v  a2 s. co  m*/
 * @param assets
 * @param filePath
 */
public void load(final AssetManager assets, final String filePath) {
    Log.v(TAG, "load(): " + filePath);

    final ReadTextFileTask readTask = new ReadTextFileTask(assets, filePath);
    if (readTask.run()) {
        Log.v(TAG, "Load success: " + filePath);

        try {
            if (mListener != null) {
                mListener.onLoad(NovaLoader.this, filePath, new NovaVO(readTask.getContent()));
            }
        } catch (JSONException e) {
            Log.e(TAG, "Load JSON failed: " + filePath, e);

            if (mListener != null) {
                mListener.onError(NovaLoader.this, filePath);
            }
        }

    } else {
        Log.e(TAG, "Load failed: " + filePath);

        if (mListener != null) {
            mListener.onError(NovaLoader.this, filePath);
        }
    }
}

From source file:com.google.android.mms.transaction.HttpUtils.java

/**
 * A helper method to send or retrieve data through HTTP protocol.
 *
 * @param token The token to identify the sending progress.
 * @param url The URL used in a GET request. Null when the method is
 *         HTTP_POST_METHOD.//ww w. ja va 2 s  . c om
 * @param pdu The data to be POST. Null when the method is HTTP_GET_METHOD.
 * @param method HTTP_POST_METHOD or HTTP_GET_METHOD.
 * @return A byte array which contains the response data.
 *         If an HTTP error code is returned, an IOException will be thrown.
 * @throws IOException if any error occurred on network interface or
 *         an HTTP error code(&gt;=400) returned from the server.
 */
public static byte[] httpConnection(Context context, long token, String url, byte[] pdu, int method,
        boolean isProxySet, String proxyHost, int proxyPort) throws IOException {
    if (url == null) {
        throw new IllegalArgumentException("URL must not be null.");
    }

    if (LOCAL_LOGV) {
        Log.v(TAG, "httpConnection: params list");
        Log.v(TAG, "\ttoken\t\t= " + token);
        Log.v(TAG, "\turl\t\t= " + url);
        Log.v(TAG, "\tmethod\t\t= "
                + ((method == HTTP_POST_METHOD) ? "POST" : ((method == HTTP_GET_METHOD) ? "GET" : "UNKNOWN")));
        Log.v(TAG, "\tisProxySet\t= " + isProxySet);
        Log.v(TAG, "\tproxyHost\t= " + proxyHost);
        Log.v(TAG, "\tproxyPort\t= " + proxyPort);
        // TODO Print out binary data more readable.
        //Log.v(TAG, "\tpdu\t\t= " + Arrays.toString(pdu));
    }

    AndroidHttpClient client = null;

    try {
        // Make sure to use a proxy which supports CONNECT.
        URI hostUrl = new URI(url);
        HttpHost target = new HttpHost(hostUrl.getHost(), hostUrl.getPort(), HttpHost.DEFAULT_SCHEME_NAME);

        client = createHttpClient(context);
        HttpRequest req = null;
        switch (method) {
        case HTTP_POST_METHOD:
            ProgressCallbackEntity entity = new ProgressCallbackEntity(context, token, pdu);
            // Set request content type.
            entity.setContentType("application/vnd.wap.mms-message");

            HttpPost post = new HttpPost(url);
            post.setEntity(entity);
            req = post;
            break;
        case HTTP_GET_METHOD:
            req = new HttpGet(url);
            break;
        default:
            Log.e(TAG, "Unknown HTTP method: " + method + ". Must be one of POST[" + HTTP_POST_METHOD
                    + "] or GET[" + HTTP_GET_METHOD + "].");
            return null;
        }

        // Set route parameters for the request.
        HttpParams params = client.getParams();
        if (isProxySet) {
            ConnRouteParams.setDefaultProxy(params, new HttpHost(proxyHost, proxyPort));
        }
        req.setParams(params);

        // Set necessary HTTP headers for MMS transmission.
        req.addHeader(HDR_KEY_ACCEPT, HDR_VALUE_ACCEPT);
        {
            String xWapProfileTagName = MmsConfig.getUaProfTagName();
            String xWapProfileUrl = MmsConfig.getUaProfUrl();

            if (xWapProfileUrl != null) {
                if (Log.isLoggable(LogTag.TRANSACTION, Log.VERBOSE)) {
                    Log.d(LogTag.TRANSACTION, "[HttpUtils] httpConn: xWapProfUrl=" + xWapProfileUrl);
                }
                req.addHeader(xWapProfileTagName, xWapProfileUrl);
            }
        }

        // Extra http parameters. Split by '|' to get a list of value pairs.
        // Separate each pair by the first occurrence of ':' to obtain a name and
        // value. Replace the occurrence of the string returned by
        // MmsConfig.getHttpParamsLine1Key() with the users telephone number inside
        // the value.
        String extraHttpParams = MmsConfig.getHttpParams();

        if (extraHttpParams != null) {
            String line1Number = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE))
                    .getLine1Number();
            String line1Key = MmsConfig.getHttpParamsLine1Key();
            String paramList[] = extraHttpParams.split("\\|");

            for (String paramPair : paramList) {
                String splitPair[] = paramPair.split(":", 2);

                if (splitPair.length == 2) {
                    String name = splitPair[0].trim();
                    String value = splitPair[1].trim();

                    if (line1Key != null) {
                        value = value.replace(line1Key, line1Number);
                    }
                    if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(value)) {
                        req.addHeader(name, value);
                    }
                }
            }
        }
        req.addHeader(HDR_KEY_ACCEPT_LANGUAGE, HDR_VALUE_ACCEPT_LANGUAGE);

        HttpResponse response = client.execute(target, req);
        StatusLine status = response.getStatusLine();
        if (status.getStatusCode() != 200) { // HTTP 200 is success.
            throw new IOException("HTTP error: " + status.getReasonPhrase());
        }

        HttpEntity entity = response.getEntity();
        byte[] body = null;
        if (entity != null) {
            try {
                if (entity.getContentLength() > 0) {
                    body = new byte[(int) entity.getContentLength()];
                    DataInputStream dis = new DataInputStream(entity.getContent());
                    try {
                        dis.readFully(body);
                    } finally {
                        try {
                            dis.close();
                        } catch (IOException e) {
                            Log.e(TAG, "Error closing input stream: " + e.getMessage());
                        }
                    }
                }
            } finally {
                if (entity != null) {
                    entity.consumeContent();
                }
            }
        }
        return body;
    } catch (URISyntaxException e) {
        handleHttpConnectionException(e, url);
    } catch (IllegalStateException e) {
        handleHttpConnectionException(e, url);
    } catch (IllegalArgumentException e) {
        handleHttpConnectionException(e, url);
    } catch (SocketException e) {
        handleHttpConnectionException(e, url);
    } catch (Exception e) {
        handleHttpConnectionException(e, url);
    } finally {
        if (client != null) {
            client.close();
        }
    }
    return null;
}

From source file:org.mythtv.service.dvr.v25.UpcomingHelperV25.java

public boolean process(final Context context, final LocationProfile locationProfile) {
    Log.v(TAG, "process : enter");

    if (!NetworkHelper.getInstance().isMasterBackendConnected(context, locationProfile)) {
        Log.w(TAG, "process : Master Backend '" + locationProfile.getHostname() + "' is unreachable");

        return false;
    }/*w  w w.jav a2 s  . co  m*/

    mMythServicesTemplate = (MythServicesTemplate) MythAccessFactory.getServiceTemplateApiByVersion(mApiVersion,
            locationProfile.getUrl());

    boolean passed = true;

    try {

        downloadUpcoming(context, locationProfile);

    } catch (Exception e) {
        Log.e(TAG, "process : error", e);

        passed = false;
    }

    Log.v(TAG, "process : exit");
    return passed;
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.v(TAG, "onCreated");
    super.onCreate(savedInstanceState);
    _activity = this;

    // set app to fullscreen
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    // layout/*ww w .  java 2  s  .  com*/
    setContentView(R.layout.activity_ranch);

    // Socket, Location Manager, Weather Manager
    locationListener = new MyLocationListener(this);
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    socket = new SocketIO();
    weatherManager = new WeatherManager(this);

    // layout items
    theTextView = (TextView) findViewById(R.id.txtMessage);
    forceButton = (Button) findViewById(R.id.btnGetLocation);
    waitButton = (Button) findViewById(R.id.btnWaitLocation);
    loadEncounterButton = (Button) findViewById(R.id.btnLoadEncounter);

    // TODO get rid of this. For now, reset the encounters file whenever created
    ConfigManager.ResetConfigFiles(getApplicationContext());

    forceButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            Log.v(TAG, "Force Click");

            // Ensure connected
            if (!isNetworkAvailable()) {
                setMessage("No internet connection.");
                return;
            }

            forceButton.setText("...");

            // Connect to server
            connectSocket();

            // Best provider
            Criteria criteria = new Criteria();
            String bestProvider = locationManager.getBestProvider(criteria, false);

            // Request location updates
            locationManager.requestLocationUpdates(bestProvider, 10000, 0, locationListener);

            forceButton.setEnabled(false);
            loadEncounterButton.setEnabled(false);
        }
    });

    waitButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Log.v(TAG, "Wait click");
            waitButton.setText("...");

            // Start Encounter Service
            // TODO Service should be started at boot?
            _activity.startService(new Intent(_activity, EncounterService.class));

            waitButton.setEnabled(false);
        }

    });

    loadEncounterButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            Log.v(TAG, "Load encounter clicked");

            // Ensure connection
            if (!isNetworkAvailable()) {
                setMessage("No internet connection.");
                return;
            }

            // Pull encounter
            String encounter = ConfigManager.PullEncounter(getApplicationContext());
            if (encounter.equals(""))
                return;

            // Use location & time from gathered string to query encounter
            String[] location = encounter.split(",");
            String latitude = location[0];
            String longitude = location[1];
            // TODO We cannot get historical weatherdata accurately. So we will just use the current time :(

            // Pop used encounter from queue
            ConfigManager.PopEncounter(getApplicationContext());

            // Server & weather
            connectSocket();
            weatherManager.execute(longitude, latitude);
            while (!socket.isConnected())
                ;

            // Send query to server
            sendLocation(longitude, latitude);
        }
    });

    // Change the text value of the loadEncounterButton to the number of encounters available
    timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            runOnUiThread(new Runnable() {
                public void run() {
                    loadEncounterButton.setText("" + ConfigManager.EncounterCount(getApplicationContext()));
                }
            });
        }
    }, 0, UPDATE_DELAY);
}

From source file:com.example.fastgive.CaptureActivity.java

@Override
protected void onResume() {
    super.onResume();
    Log.v(TAG, "onResume()");
}