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:com.eggwall.SoundSleep.AudioService.java

/**
 * Start playing the resource specified here.
 *
 * @param type Either MUSIC, or WHITE_NOISE. Passing the same ID twice
 *             is a signal to stop playing music altogether.
 *//*from   w  w w  .  ja va2  s  .  c om*/
private void play(int type) {
    if (type == MUSIC) {
        final MediaPlayer player = tryStartingMusic();
        if (player != null) {
            mPlayer = player;
            mPlayer.prepareAsync();
            // onPrepared will get called when the media player is ready to play.
            return;
        }
    }
    // Either we weren't able to play custom music, or we were asked to play white noise.
    final int resourceToPlay;
    if (type == WHITE_NOISE) {
        Log.v(TAG, "Playing white noise.");
        resourceToPlay = R.raw.noise;
    } else {
        Log.v(TAG, "Playing included jingle.");
        resourceToPlay = R.raw.jingle;
    }
    try {
        final AssetFileDescriptor d = getResources().openRawResourceFd(resourceToPlay);
        if (d == null) {
            Log.wtf(TAG, "Could not open the file to play");
            return;
        }
        final FileDescriptor fd = d.getFileDescriptor();
        mPlayer = getGenericMediaPlayer();
        mPlayer.setDataSource(fd, d.getStartOffset(), d.getLength());
        d.close();
        // White noise or the default song is looped forever.
        mPlayer.setLooping(true);
    } catch (IOException e) {
        Log.e(TAG, "Could not create a media player instance. Full error below.");
        e.printStackTrace();
        return;
    }
    postSuccessMessage(mTypePlaying);
    mPlayer.prepareAsync();
}

From source file:com.thelastcrusade.soundstream.components.ConnectFragment.java

private IMessagingService getMessagingService() {
    MessagingService messagingService = null;
    try {/*from w w  w  .  ja  va  2  s  . c om*/
        messagingService = this.messagingServiceLocator.getService();
    } catch (ServiceNotBoundException e) {
        Log.wtf(TAG, e);
    }
    return messagingService;
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppReferenceObj.java

@Override
public void activate(Context context, SignedObj obj) {
    JSONObject content = obj.getJson();//from  w  ww . j av a 2 s.  c  o m
    if (DBG)
        Log.d(TAG, "activating from appReferenceObj: " + content);

    if (!content.has(DbObject.CHILD_FEED_NAME)) {
        Log.wtf(TAG, "Bad app reference found.");
        Toast.makeText(context, "Could not launch application.", Toast.LENGTH_SHORT).show();
        return;
    }

    Log.w(TAG, "Using old-school app launch");
    SignedObj appContent = getAppStateForChildFeed(context, obj);
    if (appContent == null) {
        Intent launch = AppStateObj.getLaunchIntent(context, obj);
        if (!(context instanceof Activity)) {
            launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }

        context.startActivity(launch);
    } else {
        if (DBG)
            Log.d(TAG, "pulled app state " + appContent);
        try {
            appContent.getJson().put(PACKAGE_NAME, content.get(PACKAGE_NAME));
            appContent.getJson().put(OBJ_INTENT_ACTION, content.get(OBJ_INTENT_ACTION));
            appContent.getJson().put(DbObject.CHILD_FEED_NAME, content.get(DbObject.CHILD_FEED_NAME));
        } catch (JSONException e) {
        }
        //mAppStateObj.activate(context, appContent);
        Log.wtf(TAG, "dead code exception");
    }
}

From source file:com.github.gfx.android.orma.example.fragment.BenchmarkFragment.java

void run() {
    Log.d(TAG, "Start performing a set of benchmarks");

    adapter.clear();//from   w  ww  .  j a  v a2 s . c  om

    Realm realm = Realm.getDefaultInstance();
    realm.executeTransaction(r -> r.delete(RealmTodo.class));
    realm.close();

    hw.getWritableDatabase().execSQL("DELETE FROM todo");

    @SuppressLint("unused")
    Disposable disposable = orma.deleteFromTodo().executeAsSingle().subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread()).flatMap(integer -> startInsertWithOrma())
            .flatMap(result -> {
                adapter.add(result);
                return startInsertWithRealm(); // Realm objects can only be accessed on the thread they were created.
            }).flatMap(result -> {
                adapter.add(result);
                return startInsertWithHandWritten();
            }).flatMap(result -> {
                adapter.add(result);
                return startSelectAllWithOrma();
            }).flatMap(result -> {
                adapter.add(result);
                return startSelectAllWithRealm(); // Realm objects can only be accessed on the thread they were created.
            }).flatMap(result -> {
                adapter.add(result);
                return startSelectAllWithHandWritten();
            }).subscribe(result -> {
                adapter.add(result);
            }, error -> {
                Log.wtf(TAG, error);
                Toast.makeText(getContext(), error.getMessage(), Toast.LENGTH_LONG).show();

            });
}

From source file:com.android.calendar.agenda.AgendaFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    int screenWidth = mActivity.getResources().getDisplayMetrics().widthPixels;
    View v = inflater.inflate(R.layout.agenda_fragment, null);

    mAgendaListView = (AgendaListView) v.findViewById(R.id.agenda_events_list);
    mAgendaListView.setClickable(true);/*from ww w.  java  2  s .c o  m*/

    if (savedInstanceState != null) {
        long instanceId = savedInstanceState.getLong(BUNDLE_KEY_RESTORE_INSTANCE_ID, -1);
        if (instanceId != -1) {
            mAgendaListView.setSelectedInstanceId(instanceId);
        }
    }

    View eventView = v.findViewById(R.id.agenda_event_info);
    if (!mShowEventDetailsWithAgenda) {
        eventView.setVisibility(View.GONE);
    }

    View topListView;
    // Set adapter & HeaderIndexer for StickyHeaderListView
    StickyHeaderListView lv = (StickyHeaderListView) v.findViewById(R.id.agenda_sticky_header_list);
    if (lv != null) {
        Adapter a = mAgendaListView.getAdapter();
        lv.setAdapter(a);

        if (a instanceof HeaderViewListAdapter) {
            mAdapter = (AgendaWindowAdapter) ((HeaderViewListAdapter) a).getWrappedAdapter();
            if (mLaunchedInShareMode) {
                mAdapter.launchInShareMode(true, mShouldSelectSingleEvent);
                mAgendaListView.launchInShareMode(true, mShouldSelectSingleEvent);
                if (mShareEventListener != null) {
                    mAgendaListView.setShareEventListener(mShareEventListener);
                }
            }
            lv.setIndexer(mAdapter);
            lv.setHeaderHeightListener(mAdapter);

        } else if (a instanceof AgendaWindowAdapter) {
            mAdapter = (AgendaWindowAdapter) a;
            lv.setIndexer(mAdapter);
            lv.setHeaderHeightListener(mAdapter);

        } else {
            Log.wtf(TAG, "Cannot find HeaderIndexer for StickyHeaderListView");
        }

        // Set scroll listener so that the date on the ActionBar can be set while
        // the user scrolls the view
        lv.setOnScrollListener(this);
        lv.setHeaderSeparator(getResources().getColor(R.color.agenda_list_separator_color), 1);
        topListView = lv;
    } else {
        topListView = mAgendaListView;
    }

    // Since using weight for sizing the two panes of the agenda fragment causes the whole
    // fragment to re-measure when the sticky header is replaced, calculate the weighted
    // size of each pane here and set it

    if (!mShowEventDetailsWithAgenda) {
        ViewGroup.LayoutParams params = topListView.getLayoutParams();
        params.width = screenWidth;
        topListView.setLayoutParams(params);
    } else {
        ViewGroup.LayoutParams listParams = topListView.getLayoutParams();
        listParams.width = screenWidth * 4 / 10;
        topListView.setLayoutParams(listParams);
        ViewGroup.LayoutParams detailsParams = eventView.getLayoutParams();
        detailsParams.width = screenWidth - listParams.width;
        eventView.setLayoutParams(detailsParams);
    }
    return v;
}

From source file:de.skubware.opentraining.activity.create_workout.ExerciseTypeDetailFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    // MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.exercise_detail_menu, menu);

    // configure menu_item_add_exercise
    MenuItem menu_item_add_exercise = (MenuItem) menu.findItem(R.id.menu_item_add_exercise);
    menu_item_add_exercise.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {

            // assert, that an exercise was choosen
            if (mExercise == null) {
                Log.wtf(TAG, "No exercise has been choosen. This should not happen");
                return true;
            }/* ww  w .  j  av a2s  .  co  m*/

            // add exercise to workout or create a new one
            if (mWorkout == null) {
                SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getActivity());
                String defaultWorkoutName = settings.getString("default_workout_name", "Workout");

                mWorkout = new Workout(defaultWorkoutName, new FitnessExercise(mExercise));
            } else {

                // assert that there is not already such an exercise in the
                // workout
                for (FitnessExercise fEx : mWorkout.getFitnessExercises()) {
                    if (fEx.getExType().equals(mExercise)) {
                        Toast.makeText(getActivity(), getString(R.string.exercise_already_in_workout),
                                Toast.LENGTH_LONG).show();
                        return true;
                    }
                }

                mWorkout.addFitnessExercise(new FitnessExercise(mExercise));
            }

            // update Workout in Activity
            if (getActivity() instanceof Callbacks) {
                // was launched by ExerciseTypeListActivity
                ((Callbacks) getActivity()).onWorkoutChanged(mWorkout);
            } else {
                // was launched by ExerciseTypeDetailActivity
                Intent i = new Intent();
                i.putExtra(ExerciseTypeListActivity.ARG_WORKOUT, mWorkout);
                getActivity().setResult(Activity.RESULT_OK, i);
                getActivity().finish();
            }

            Toast.makeText(getActivity(), getString(R.string.exercise) + " " + mExercise.getLocalizedName()
                    + " " + getString(R.string.has_been_added), Toast.LENGTH_SHORT).show();

            return true;
        }
    });

    // configure menu_item_license_info
    MenuItem menu_item_license_info = (MenuItem) menu.findItem(R.id.menu_item_license_info);
    menu_item_license_info.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle(getString(R.string.license_info));

            String license = "";

            if (mExercise.getImageLicenseMap().values().iterator().hasNext()) {
                license = mExercise.getImageLicenseMap().values().iterator().next().toString();
            } else {
                license = getString(R.string.no_license_available);
            }

            builder.setMessage(license);
            builder.create().show();

            return true;
        }
    });

    // configure menu_item_description
    MenuItem menu_item_description = (MenuItem) menu.findItem(R.id.menu_item_description);
    menu_item_description.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            if (mExercise.getDescription() == null || mExercise.getDescription().equals("")) {
                Toast.makeText(getActivity(), getString(R.string.no_description_available), Toast.LENGTH_LONG)
                        .show();
                return true;
            }

            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setTitle(getString(R.string.description));

            builder.setMessage(Html.fromHtml(mExercise.getDescription()));
            builder.create().show();

            return true;
        }
    });

    // configure menu_item_delete_exercise
    if (mExercise != null && mExercise.getExerciseSource() == ExerciseSource.CUSTOM) {
        MenuItem menu_item_delete_exercise = (MenuItem) menu.findItem(R.id.menu_item_delete_exercise);
        menu_item_delete_exercise.setVisible(true);
        menu_item_delete_exercise.setOnMenuItemClickListener(new OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                IDataProvider dataProvider = new DataProvider(getActivity());
                dataProvider.deleteCustomExercise(mExercise);

                if (getActivity() instanceof Callbacks) {
                    // was launched by ExerciseTypeListActivity
                    ((Callbacks) getActivity()).onExerciseDeleted(mExercise);
                } else {
                    // was launched by ExerciseTypeDetailActivity
                    Intent i = new Intent();
                    i.putExtra(ARG_DELETED_EXERCISE, mExercise);
                    getActivity().setResult(RESULT_EXERCISE_CHANGED, i);
                    getActivity().finish();
                }

                return false;
            }
        });
    }

    // configure menu_item_upload_exercise
    MenuItem menu_item_upload_exercise = (MenuItem) menu.findItem(R.id.menu_item_upload_exercise);
    menu_item_upload_exercise.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            Context context = ExerciseTypeDetailFragment.this.getActivity();

            //UploadExerciseAsyncTask exUpload = new UploadExerciseAsyncTask(context);
            //exUpload.execute(mExercise);

            UploadExerciseImagesAsyncTask exImageUpload = new UploadExerciseImagesAsyncTask(context);
            exImageUpload.execute(mExercise);

            return true;
        }
    });

    // configure menu_item_send_exercise_feedback
    MenuItem menu_item_delete_exercise = (MenuItem) menu.findItem(R.id.menu_item_send_exercise_feedback);
    menu_item_delete_exercise.setVisible(true);
    menu_item_delete_exercise.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {

            FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
            Fragment prev = getActivity().getSupportFragmentManager().findFragmentByTag("dialog");
            if (prev != null) {
                ft.remove(prev);
            }
            ft.addToBackStack(null);

            // Create and show the dialog.
            DialogFragment newFragment = SendExerciseFeedbackDialogFragment.newInstance(mExercise);
            newFragment.show(ft, "dialog");

            return false;
        }
    });

}

From source file:org.jivesoftware.spark.util.DummySSLSocketFactory.java

public Socket createSocket(String s, int i, InetAddress inaddr, int j) throws IOException {
    AsyncTask<Object, Void, Object> socketCreationTask = new AsyncTask<Object, Void, Object>() {
        @Override//  w ww  . j  ava  2 s. co  m
        protected Object doInBackground(Object... params) {
            Object ret;
            try {
                ret = factory.createSocket((String) params[0], (int) params[1], (InetAddress) params[2],
                        (int) params[3]);
            } catch (Exception e) {
                Log.wtf("F8 :" + getClass().getName(), e);
                ret = e;
            }
            return ret;
        }
    };
    //It's necessary to run the task in an executor because the main one is already full and if we
    // add this one a livelock will occur
    ExecutorService socketCreationExecutor = Executors.newFixedThreadPool(1);
    socketCreationTask.executeOnExecutor(socketCreationExecutor, s, i, inaddr, j);
    Object returned;
    try {
        returned = socketCreationTask.get();
    } catch (InterruptedException | ExecutionException e) {
        Log.wtf("F9 :" + getClass().getName(), e);
        throw new IOException("Failure intentionally provoked. See log above.");
    }

    if (returned instanceof Exception) {
        throw (IOException) returned;
    } else {
        return (Socket) returned;
    }
}

From source file:com.thelastcrusade.soundstream.components.PlaylistFragment.java

protected PlaylistService getPlaylistService() {
    PlaylistService playlistService = null;

    try {//from  www .j  av a  2s.c  o m
        playlistService = this.playlistServiceServiceLocator.getService();
    } catch (ServiceNotBoundException e) {
        Log.wtf(TAG, e);
    }
    return playlistService;
}

From source file:com.skalski.raspberrycontrol.Custom_WebSocketClient.java

@Override
public void onRawTextMessage(byte[] payload) {
    Log.wtf(LOGTAG, LOGPREFIX + "we didn't expect 'RawText' Message");
}

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

@Override
public void onResume() {
    super.onResume(); // Always call the superclass method first
    if (prefs.getBoolean("firstrun", true)) {
        mDrawerLayout.openDrawer(mDrawerList);
        Intent intent = new Intent(this, EmailActivity.class);
        startActivity(intent);/*w  w w  . ja  v  a  2 s . c  om*/
        prefs.edit().putBoolean("firstrun", false).commit();

    }

    try {
        FileInputStream fis = this.openFileInput("json_file");
        BufferedReader br = new BufferedReader(new InputStreamReader(fis));
        StringBuilder outputstring = new StringBuilder();
        String chunk = null;
        try {
            while ((chunk = br.readLine()) != null) {
                outputstring.append(chunk);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        mCacheJSONString = outputstring.toString();

        parseItemList(mCacheJSONString);

    } catch (IOException e) {
        Log.wtf("MainActivity on Resume", "could not find file");
    }

}