Example usage for android.util Log w

List of usage examples for android.util Log w

Introduction

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

Prototype

public static int w(String tag, Throwable tr) 

Source Link

Usage

From source file:com.riksof.a320.c2dm.common.C2DMReceiver.java

@Override
public void onRegistered(Context context, String registrationId) {
    HttpClient httpclient = new DefaultHttpClient();
    Log.w("C2DMReceiver-onRegistered", "Sending request to Server");

    HttpPost httppost = new HttpPost(getResources().getString(R.string.server_url));

    // Add your data
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
    nameValuePairs.add(new BasicNameValuePair("deviceToken", registrationId));
    nameValuePairs.add(new BasicNameValuePair("sdkType", "Android"));
    nameValuePairs.add(new BasicNameValuePair("openUDID", getOpenUDID(this.getBaseContext())));
    nameValuePairs.add(new BasicNameValuePair("deviceId", getAndroidId(this.getBaseContext())));
    try {//from  w w w. j a va 2s. c o  m
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    } catch (UnsupportedEncodingException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    try {
        HttpResponse response = httpclient.execute(httppost);
        System.out.println(response);
    } catch (Exception e) {
        Log.e("C2DMReceiver-onRegistered", e.getMessage());
    }
    Log.w("C2DMReceiver-onRegistered", registrationId);
}

From source file:fr.cph.stock.android.task.MainTask.java

@Override
protected Boolean doInBackground(Void... params) {
    boolean toReturn = true;
    Connect connect = Connect.getInstance();
    connect.setRequest(url.getUrl() + this.params);
    try {/*from   w w w .j av  a  2s  .c  om*/
        json = connect.getJSONObject();
    } catch (AppException e) {
        Log.w(TAG, e.getMessage());
        this.error = e.getMessage();
        toReturn = false;
    }
    if (json != null) {
        String errorMessage = json.optString("error");
        if (!errorMessage.equals("")) {
            this.error = errorMessage;
            toReturn = false;
        }
    }
    return toReturn;
}

From source file:co.hmsk.android.webdbpress76.util.Security.java

/**
 * Verifies that the data was signed with the given signature, and returns
 * the verified purchase. The data is in JSON format and signed
 * with a private key. The data also contains the {@link PurchaseState}
 * and product ID of the purchase./*from  ww  w.  jav  a  2 s .  com*/
 * @param base64PublicKey the base64-encoded public key to use for verifying.
 * @param signedData the signed JSON string (signed, not encrypted)
 * @param signature the signature for the data, signed with the private key
 */
public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) {
    if (signedData == null) {
        Log.e(TAG, "data is null");
        return false;
    }

    boolean verified = false;
    if (!TextUtils.isEmpty(signature)) {
        PublicKey key = Security.generatePublicKey(base64PublicKey);
        verified = Security.verify(key, signedData, signature);
        if (!verified) {
            Log.w(TAG, "signature does not match data.");
            return false;
        }
    }
    return true;
}

From source file:com.markupartist.sthlmtraveling.provider.departure.DeparturesStore.java

public Departures find(Context context, Site site) throws IllegalArgumentException, IOException {
    if (site == null) {
        Log.w(TAG, "Site is null");
        throw new IllegalArgumentException(TAG + ", Site is null");
    }/*w w  w  .  j a  v a2  s .co m*/

    Log.d(TAG, "About to get departures for " + site.getName());
    String endpoint = apiEndpoint2() + "v1/departures/" + site.getId() + "?key=" + get(KEY) + "&timewindow=30";

    HttpHelper httpHelper = HttpHelper.getInstance(context);
    HttpURLConnection connection = httpHelper.getConnection(endpoint);

    if (connection.getResponseCode() != 200) {
        Log.w(TAG, "A remote server error occurred when getting departures, status code: "
                + connection.getResponseCode());
        throw new IOException("A remote server error occurred when getting departures.");
    }

    Departures departures;
    String rawContent = httpHelper.getBody(connection);
    try {
        departures = Departures.fromJson(new JSONObject(rawContent));
    } catch (JSONException e) {
        Crashlytics.logException(e);
        Log.d(TAG, "Could not parse the departure reponse.");
        throw new IOException("Could not parse the response.");
    }

    return departures;
}

From source file:com.kuya.cordova.plugin.util.Security.java

/**
 * Verifies that the data was signed with the given signature, and returns
 * the verified purchase. The data is in JSON format and signed
 * with a private key. The data also contains the {@link PurchaseState}
 * and product ID of the purchase./*from   w  ww .j  a  v  a2s  .  com*/
 * @param base64PublicKey the base64-encoded public key to use for verifying.
 * @param signedData the signed JSON string (signed, not encrypted)
 * @param signature the signature for the data, signed with the private key
 */
public static boolean verifyPurchase(String base64PublicKey, String signedData, String signature) {

    if (signedData == null) {
        Log.e(TAG, "data is null");
        return false;
    }
    boolean verified = false;
    if (!TextUtils.isEmpty(signature)) {
        PublicKey key = Security.generatePublicKey(base64PublicKey);
        verified = Security.verify(key, signedData, signature);
        if (!verified) {
            Log.w(TAG, "signature does not match data.");
            return false;
        }
    }

    return true;
    /*
    // commented because http://stackoverflow.com/questions/19732025/android-in-app-billing-purchase-verification-failed
            
    if (TextUtils.isEmpty(signedData) || TextUtils.isEmpty(base64PublicKey) ||
        TextUtils.isEmpty(signature)) {
    Log.e(TAG, "Purchase verification failed: missing data.");
    return false;
    }
            
    PublicKey key = Security.generatePublicKey(base64PublicKey);
    return Security.verify(key, signedData, signature);
    */
}

From source file:de.jamoo.muzei.WallSource.java

public void onCreate() {
    if (DEBUG)/*from   w w  w .  j a  va 2 s . c om*/
        Log.w(TAG, "onCreate");
    super.onCreate();

    ArrayList<UserCommand> commands = new ArrayList<UserCommand>();
    commands.add(new UserCommand(BUILTIN_COMMAND_ID_NEXT_ARTWORK));
    commands.add(new UserCommand(COMMAND_ID_SHARE, getString(R.string.action_share_app)));

    setUserCommands(commands);

    PreferenceHelper.limitConfigFreq(this);
}

From source file:cn.code.notes.gtask.data.MetaData.java

@Override
public void setContentByRemoteJSON(JSONObject js) {
    super.setContentByRemoteJSON(js);
    if (getNotes() != null) {
        try {/*from w w  w  .  jav  a2 s  .c om*/
            JSONObject metaInfo = new JSONObject(getNotes().trim());
            mRelatedGid = metaInfo.getString(GTaskStringUtils.META_HEAD_GTASK_ID);
        } catch (JSONException e) {
            Log.w(TAG, "failed to get related gid");
            mRelatedGid = null;
        }
    }
}

From source file:net.bible.android.control.BibleContentManager.java

public void updateText(boolean forceUpdate) {
    CurrentPage currentPage = CurrentPageManager.getInstance().getCurrentPage();
    Book document = currentPage.getCurrentDocument();
    Key key = currentPage.getKey();

    // check for duplicate scren update requests
    if (!forceUpdate && document.equals(displayedBible) && key.equals(displayedVerse)) {
        Log.w(TAG, "Duplicated screen update. Doc:" + document.getInitials() + " Key:" + key);
    }/*from w  w  w  .  j a  v a 2  s  . c o  m*/
    new UpdateTextTask().execute(currentPage);
}

From source file:com.norman0406.slimgress.API.Interface.RequestResult.java

public static void handleRequest(JSONObject json, RequestResult result) {
    if (result == null)
        throw new RuntimeException("invalid result object");

    try {//from   w  w  w .j  a va 2  s .c  o m
        // handle exception string if available
        String excString = json.optString("exception");
        if (excString.length() > 0)
            result.handleException(excString);

        // handle error code if available
        String error = json.optString("error");
        if (error.length() > 0)
            result.handleError(error);
        else if (json.has("error"))
            Log.w("RequestResult", "request contains an unknown error type");

        // handle game basket if available
        JSONObject gameBasket = json.optJSONObject("gameBasket");
        if (gameBasket != null)
            result.handleGameBasket(new GameBasket(gameBasket));

        // handle result if available
        JSONObject resultObj = json.optJSONObject("result");
        JSONArray resultArr = json.optJSONArray("result");
        String resultStr = json.optString("result");
        if (resultObj != null)
            result.handleResult(resultObj);
        else if (resultArr != null)
            result.handleResult(resultArr);
        else if (resultStr != null)
            result.handleResult(resultStr);
        else if (json.has("result"))
            Log.w("RequestResult", "request contains an unknown result type");

        result.finished();
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.xtremelabs.imageutils.DefaultNetworkRequestCreator.java

@Override
public void getInputStream(String url, InputStreamListener listener) {
    HttpEntity entity = null;/* w  w w  . j a v  a2 s.  c o  m*/
    InputStream inputStream = null;

    HttpClient client = new DefaultHttpClient();
    client.getConnectionManager().closeExpiredConnections();
    HttpUriRequest request;
    try {
        request = new HttpGet(url);
    } catch (IllegalArgumentException e) {
        try {
            request = new HttpGet(URLEncoder.encode(url, "UTF-8"));
        } catch (UnsupportedEncodingException e1) {
            String errorMessage = "Unable to download image. Reason: Bad URL. URL: " + url;
            Log.w(ImageLoader.TAG, errorMessage);
            listener.onFailure(errorMessage);
            return;
        }
    }
    HttpResponse response;
    try {
        response = client.execute(request);

        entity = response.getEntity();
        if (entity == null) {
            listener.onFailure("Was unable to retrieve an HttpEntity for the image!");
            return;
        }

        inputStream = new BufferedInputStream(entity.getContent());
        listener.onInputStreamReady(inputStream);
    } catch (IOException e) {
        listener.onFailure("IOException caught when attempting to download an image! Stack trace below. URL: "
                + url + ", Message: " + e.getMessage());
        e.printStackTrace();
    }

    try {
        if (entity != null) {
            entity.consumeContent();
        }
    } catch (IOException e) {
    }

    client.getConnectionManager().closeExpiredConnections();
}