Example usage for android.util Log wtf

List of usage examples for android.util Log wtf

Introduction

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

Prototype

public static int wtf(String tag, Throwable tr) 

Source Link

Document

What a Terrible Failure: Report an exception that should never happen.

Usage

From source file:gxu.software_engineering.market.android.service.SyncService.java

@Override
protected void onHandleIntent(Intent intent) {
    //      ??//  ww w.  j  a v  a2  s  .c  om
    if (!NetworkUtils.connected(getApplicationContext())) {
        return;
    }
    //      ??
    long lastSyncMills = app.getPrefs().getLong(C.LAST_SYNC, 0);
    if (lastSyncMills == 0L) {
        Calendar c = Calendar.getInstance();
        c.set(Calendar.YEAR, 1980);
        lastSyncMills = c.getTimeInMillis();
    }

    String uri = C.DOMAIN + String.format("/sync?count=%d&last=%s", C.DEFAULT_LIST_SIZE, lastSyncMills);

    JSONObject result = null;
    try {
        result = RESTMethod.get(uri);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
    boolean nice = false;
    ContentValues[] categories = null;
    ContentValues[] users = null;
    ContentValues[] items = null;
    try {
        if (result.getInt(C.STATUS) == C.OK) {
            nice = true;
            categories = Processor.toCategories(result.getJSONArray(C.CATEGORIES));
            users = Processor.toUsers(result.getJSONArray(C.USERS));
            items = Processor.toItems(result.getJSONArray(C.ITEMS));
        } else {
            throw new RuntimeException(result.getString(C.MSG));
        }
    } catch (Exception e) {
        Log.wtf("synv json result error!", e);
        final String msg = e.getMessage();
        handler.post(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(getApplicationContext(), getResources().getString(R.string.sync_error, msg),
                        Toast.LENGTH_SHORT).show();
            }
        });
    }

    if (nice) {
        getContentResolver().bulkInsert(Uri.parse(C.BASE_URI + C.CATEGORIES), categories);
        getContentResolver().bulkInsert(Uri.parse(C.BASE_URI + C.USERS), users);
        getContentResolver().bulkInsert(Uri.parse(C.BASE_URI + C.ITEMS), items);

        final long now = System.currentTimeMillis();

        //         
        app.getPrefs().edit().putLong(C.LAST_SYNC, now).commit();

        //         ????
        handler.post(new Runnable() {

            @Override
            public void run() {
                Toast.makeText(getApplicationContext(),
                        getResources().getString(R.string.sync_nice, DateUtils.getRelativeTimeSpanString(now)),
                        Toast.LENGTH_SHORT).show();
            }
        });
    }
}

From source file:com.makerfaireorlando.app.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //Assume true if the key does not yet exist
    prefs = getSharedPreferences("com.makerfaireorlando.app", MODE_PRIVATE);
    mCategories = new ArrayList<String>();

    if (savedInstanceState != null) {
        // Restore last state for checked position.
        mCurCheckPosition = savedInstanceState.getString("curChoice");
    } else {/*  ww w  . j a  va2s .  c om*/
        try {
            getItemList();
        } catch (JSONException e) {
            Log.wtf("Main Activity", "Failed to get Item List");
        }
    }

    setContentView(R.layout.activity_main);

    //getSupportActionBar().setLogo(R.drawable.ic_actionbar);
    mTitle = mDrawerTitle = getTitle();
    titles = getResources().getStringArray(R.array.selection_array);

    classes = getResources().getStringArray(R.array.nav_classes);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, titles));

    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

    // enable ActionBar app icon to behave as action ClickListenerto toggle nav drawer
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_navigation_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getSupportActionBar().setTitle(mTitle);
            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
                invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            }
            //getSupportFragmentManager().findFragmentByTag(mCurCheckPosition).setMenuVisibility(true);
        }

        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mDrawerTitle);
            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
                invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            }
            //getSupportFragmentManager().findFragmentByTag(mCurCheckPosition).setMenuVisibility(false);

        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
        FragmentTransaction tx = getSupportFragmentManager().beginTransaction().addToBackStack(null);
        tx.replace(R.id.content_frame, Fragment.instantiate(MainActivity.this, classes[0]), classes[0]);
        tx.commit();
        mCurCheckPosition = classes[0];
        mDrawerList.setItemChecked(0, true);
    }

}

From source file:de.elanev.studip.android.app.backend.net.util.JacksonRequest.java

private void logResponse(String str) {
    if (BuildConfig.DEBUG)
        Log.wtf(TAG, str);
}

From source file:us.yeomans.playsync.GcmIntentService.java

private void sendNotification(String msg, String pId) {
    mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

    Intent playIntent = new Intent(this, PlayingActivity.class);
    Log.wtf("PuttingIntExtra", pId);
    playIntent.putExtra("extra_stuff", new String[] { pId, "true" });

    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, playIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.mipmap.ic_launcher).setContentTitle("Spotify PlaySync Request")
            .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg);

    mBuilder.setContentIntent(contentIntent);
    mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
}

From source file:de.jadehs.jadehsnavigator.fragment.NewsFragment.java

public void updateRSSFeeds() {
    Log.wtf(TAG, "Starting updateRSSFeeds");
    ConnectivityManager cm = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
    boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
    if (isConnected) {
        try {//from   ww  w  .  j a  v a2 s  . co  m
            /* Load RSS origins from asset file and create a list with RSS origins */
            ArrayList<RSSOrigin> origins = new ArrayList<RSSOrigin>();
            JSONObject obj = new JSONObject(loadJSONFromAsset());
            JSONArray jArray = obj.getJSONArray("origins");
            RSSOrigin rssOrigin;
            for (int i = 0; i < jArray.length(); i++) {
                JSONObject origin = jArray.getJSONObject(i);
                rssOrigin = new RSSOrigin(origin.getLong("id"), origin.getString("title"),
                        origin.getString("url"));
                origins.add(rssOrigin);
            }
            /* Start parsing */
            ParseRSSTask rssTask = new ParseRSSTask(getActivity(), origins);
            rssTask.delegate = this;
            rssTask.execute();
        } catch (Exception ex) {
            Log.wtf(TAG, "Failed to parse", ex);
        }
    } else {
        Log.wtf(TAG, "NO INTERNET CONNECTION");
        //@todo: footer
        //getActivity().findViewById(R.id.errorOverlay).setVisibility(View.VISIBLE); // Displays the error overlay
    }
}

From source file:de.skubware.opentraining.activity.MainActivity.java

/**
 * Configures the ListView for this activity.
 *///from   w  ww .  j a  va  2 s  .  c om
private void setUpList() {
    ListView listview = (ListView) this.findViewById(R.id.activity_main_listview);

    String[] values = new String[] { getString(R.string.create_workout), getString(R.string.manage_workouts),
            getString(R.string.start_training), getString(R.string.settings) };

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
            android.R.id.text1, values);

    listview.setAdapter(adapter);

    listview.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
            case 0:
                startActivity(new Intent(MainActivity.this, ExerciseTypeListActivity.class));
                break;
            case 1:
                startActivity(new Intent(MainActivity.this, WorkoutListActivity.class));
                break;
            case 2:
                showSelectWorkoutDialog();
                break;
            case 3:
                startActivity(new Intent(MainActivity.this, SettingsActivity.class));
                break;
            default:
                Log.wtf(TAG, "This item should not exist.");
            }
        }
    });
}

From source file:vee.vee.string.downloader.StringDownloader.java

/**
 * @see android.os.AsyncTask#doInBackground(java.lang.Object[])
 *///from  ww w  . jav  a 2 s  .c om
@Override
protected String doInBackground(String... params) {
    if (activity
            .checkCallingOrSelfPermission(Manifest.permission.INTERNET) == PackageManager.PERMISSION_DENIED) {
        mSetterGetter.setDownloadStatus(false);
        publishProgress(1000);
        Log.wtf(tag, StringDownloaderSnippets.noInternetPermission);
        return null;
    }

    if (debug) {
        Log.w(tag, "doInBackground");
        Log.w(tag, "Number of URL(s) :<>: " + params.length);
    }
    String url;

    for (int i = 0; i < params.length; i++) {

        if (debug) {
            Log.v(tag, "Executing");
        }

        url = params[i];

        publishProgress(1);
        if (!dialog.isShowing()) {

            try {
                dialog = new ProgressDialog(activity);
                dialog.setCancelable(false);
                dialog.setCanceledOnTouchOutside(false);
                dialog.show();
            } catch (final Exception e) {
                if (debug) {
                    Log.wtf(tag, "Dialog Exception" + e.getMessage());
                }
                continue;
            }

        }

        result = null;
        try {

            url = new URL(url).toURI().toString();

            if (debug) {
                Log.w(tag, "Executing URL :<>: " + (i + 1));
                Log.v(tag, url);
            }

            httpGet = new HttpGet(url);

            response = httpClient.execute(httpGet, mCookieJar.getLocalContext());

            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK && response.getEntity() != null) {

                publishProgress(2);

                final HttpEntity httpEntity = response.getEntity();

                result = EntityUtils.toString(httpEntity);

                // Do NOT UPDATE UI IN THREAD, Move this to PostExe
                // strgDwnLsnr.stringDownloadedSuccessfully(result);

                if (debug) {
                    Log.i(tag, "URL > " + (i + 1) + " > Downloaded Successfully");
                }
                mSetterGetter.setDownloadStatus(true);

                if (mCookieJar.getCookieStore() != null) {
                    mCookieJar.setCookieStore(mCookieJar.getCookieStore());
                }
                if (mCookieJar.getLocalContext() != null) {
                    mCookieJar.setLocalContext(mCookieJar.getLocalContext());
                }

                if (result != null) {
                    strgDwnLsnr.stringDownloadedSuccessfully(result, url, i, mCookieJar.getCookieStore());
                } else {

                    /* There is highly NO chance of coming here */

                    reasonForFailure = StringDownloaderSnippets.serverScrewed;
                    strgDwnLsnr.errorInServerSide(response.getStatusLine().getStatusCode(),
                            getStatusEquivalent(response.getStatusLine().getStatusCode()), url, i,
                            mCookieJar.getCookieStore());
                }

            } else {

                strgDwnLsnr.errorInServerSide(response.getStatusLine().getStatusCode(),
                        getStatusEquivalent(response.getStatusLine().getStatusCode()), url, i,
                        mCookieJar.getCookieStore());
                result = null;
                mSetterGetter.setDownloadStatus(false);
                publishProgress(500);
                // Do NOT UPDATE UI IN THREAD, Move this to PostExe
                // strgDwnLsnr.dataDownloadFailed();
            }
        } catch (final Exception e) {

            result = null;
            mSetterGetter.setDownloadStatus(false);
            publishProgress(1000);
            reasonForFailure = e.getMessage();
            strgDwnLsnr.stringFetchingFailed(reasonForFailure, url, i, mCookieJar.getCookieStore());
            if (debug) {
                Log.wtf(tag, reasonForFailure);
            }

        }

    }

    return result;
}

From source file:com.binil.pushnotification.ServerUtil.java

/**
 * Issue a POST request to the server.//from  w  w w.  j  a  va2 s . c  o  m
 *
 * @param endpoint POST address.
 * @param params   request parameters.
 * @throws java.io.IOException propagated from POST.
 */
private static void post(String endpoint, Map<String, Object> params) throws IOException, JSONException {

    URL url = new URL(endpoint);
    HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
    urlConnection.setRequestMethod("POST");
    urlConnection.setRequestProperty("Cache-Control", "no-cache");
    urlConnection.setRequestProperty("Content-Type", "application/json;charset=utf-8");
    urlConnection.setRequestProperty("Accept-Encoding", "gzip,deflate");
    urlConnection.setRequestProperty("Accept", "*/*");

    urlConnection.setDoOutput(true);

    JSONObject json = new JSONObject(params);
    String body = json.toString();
    urlConnection.setFixedLengthStreamingMode(body.length());

    try {
        OutputStream os = urlConnection.getOutputStream();
        os.write(body.getBytes("UTF-8"));
        os.close();

    } catch (Exception e) {
        e.printStackTrace();

    } finally {
        int status = urlConnection.getResponseCode();
        String connectionMsg = urlConnection.getResponseMessage();
        urlConnection.disconnect();

        if (status != HttpURLConnection.HTTP_OK) {
            Log.wtf(TAG, connectionMsg);
            throw new IOException("Post failed with error code " + status);
        }
    }

}

From source file:com.knurld.alphabank.com.knurld.alphabank.request.MultipartRequest.java

@Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {

    try {//from ww w. j  a  v a  2s . c  o m
        Log.i(TAG, "Network Response " + new String(response.data, "UTF-8"));
        return Response.success(new String(response.data, "UTF-8"), getCacheEntry());
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        Log.wtf(TAG, e.getMessage());
        return Response.success(new String(response.data), getCacheEntry());
    }
}

From source file:com.snicesoft.basekit.LogKit.java

public static void wtf(String content) {
    if (!allowWtf)
        return;//  w w  w. j a v a2s. c o m
    StackTraceElement caller = getCallerStackTraceElement();
    String tag = generateTag(caller);
    Log.wtf(tag, content);
}