Example usage for android.widget Toast LENGTH_LONG

List of usage examples for android.widget Toast LENGTH_LONG

Introduction

In this page you can find the example usage for android.widget Toast LENGTH_LONG.

Prototype

int LENGTH_LONG

To view the source code for android.widget Toast LENGTH_LONG.

Click Source Link

Document

Show the view or text notification for a long period of time.

Usage

From source file:com.aniruddhc.acemusic.player.AsyncTasks.AsyncCopyMoveTask.java

@Override
protected Boolean doInBackground(String... params) {

    try {//ww w. ja  v  a  2 s.  c o m
        if (mSourceFile.getCanonicalPath() == mDestinationFile.getCanonicalPath()) {
            Toast.makeText(mContext, R.string.source_target_same, Toast.LENGTH_LONG).show();
            return false;
        }

    } catch (Exception e) {
        return false;
    }

    if (mSourceFile.isDirectory()) {

        try {
            if (mShouldMove)
                FileUtils.moveDirectoryToDirectory(mSourceFile, mDestinationFile, true);
            else
                FileUtils.copyDirectoryToDirectory(mSourceFile, mDestinationFile);

        } catch (Exception e) {
            return false;
        }

    } else {

        try {
            if (mShouldMove)
                FileUtils.moveFileToDirectory(mSourceFile, mDestinationFile, true);
            else
                FileUtils.copyFile(mSourceFile, mDestinationFile);

        } catch (Exception e) {
            return false;
        }

    }

    return true;
}

From source file:com.chess.genesis.activity.LoginFrag.java

private void handleNetwork(final Message msg) {
    final JSONObject json = (JSONObject) msg.obj;

    try {/*from   www .  ja  v  a  2  s  . c  o m*/
        if (json.getString("result").equals("error")) {
            exitActivity = false;
            progress.remove();
            Toast.makeText(act, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show();
            return;
        }
    } catch (final JSONException e) {
        throw new RuntimeException(e.getMessage(), e);
    }

    switch (msg.what) {
    case NetworkClient.LOGIN:
        progress.setText("Syncing Data");

        EditText txt = (EditText) act.findViewById(R.id.username);
        final String username = txt.getText().toString().trim();

        txt = (EditText) act.findViewById(R.id.password);
        final String password = txt.getText().toString();

        final PrefEdit pref = new PrefEdit(act);
        pref.putBool(R.array.pf_isLoggedIn, true);
        pref.putString(R.array.pf_username, username);
        pref.putString(R.array.pf_passhash, password);
        pref.commit();

        SocketClient.getInstance().setIsLoggedIn(true);

        final SyncClient sync = new SyncClient(act, handle);
        sync.setSyncType(SyncClient.FULL_SYNC);
        new Thread(sync).start();
        break;
    case SyncClient.MSG:
        // start background notifier
        act.startService(new Intent(act, GenesisNotifier.class));

        final GameDataDB db = new GameDataDB(act);
        db.recalcYourTurn();
        db.close();

        sendResult(Activity.RESULT_OK);
        progress.dismiss();
        break;
    }
}

From source file:com.jakebasile.android.linkshrink.ShortenUrl.java

private void showBadInputToast() {
    Toast.makeText(this, R.string.bad_input_toast, Toast.LENGTH_LONG).show();
    finish();
}

From source file:be.ac.ucl.lfsab1509.llncampus.ExternalAppUtility.java

/**
 * Start the Google Maps application and navigate the user to the specified location.
 * /*from   www  .  j  a  v  a2  s.c  o m*/
 * @param lat
 *          Destination latitude.
 * @param lon
 *          Destination longitude.
 * @param c
 *          Current context.
 */
public static void startNavigation(float lat, float lon, Context c) {
    try {
        Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
                Uri.parse("http://maps.google.com/maps?daddr=" + lat + "," + lon + "&dirflg=w"));
        intent.setComponent(
                new ComponentName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"));
        c.startActivity(intent);

    } catch (ActivityNotFoundException e) { // If we don't have Google Maps
        Log.e("ExternalAppUtility", c.getString(R.string.no_google_maps));
        Toast t = Toast.makeText(LLNCampus.getContext().getApplicationContext(), R.string.no_google_maps,
                Toast.LENGTH_LONG);
        t.setGravity(Gravity.CENTER, 0, 0);
        t.show();
    }
}

From source file:pl.bcichecki.rms.client.android.dialogs.InboxMessageDetailsDialog.java

private void markRead() {
    if (!message.isReadByRecipent(UserProfileHolder.getUserProfile())) {
        messagesRestClient.markMessageRead(message, new AsyncHttpResponseHandler() {

            @Override//from   w  w w . ja v  a2  s. c o m
            public void onFailure(Throwable error, String content) {
                Log.d(getTag(), "Could  not mark message read [error=" + error + ", content=" + content + "]");
                if (error instanceof HttpResponseException) {
                    if (((HttpResponseException) error).getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
                        AppUtils.showCenteredToast(context, R.string.general_unathorized_error_message_title,
                                Toast.LENGTH_LONG);
                    } else {
                        AppUtils.showCenteredToast(context, R.string.general_unknown_error_message_title,
                                Toast.LENGTH_LONG);
                    }
                } else {
                    AppUtils.showCenteredToast(context, R.string.general_unknown_error_message_title,
                            Toast.LENGTH_LONG);
                }
            }

            @Override
            public void onFinish() {
                Log.d(getTag(), "Attempt markRead on " + message + " finished.");
            }

            @Override
            public void onStart() {
                Log.d(getTag(), "Attempting markRead on " + message);
            }

            @Override
            public void onSuccess(int statusCode, String content) {
                Log.d(getTag(), "Message marked read. Refreshing inboxMessagesListAdapter...");
                refreshInboxMessage(message);
            }

        });
    }
}

From source file:mx.itdurango.rober.siitdocentes.asynctasks.GruposTask.java

@Override
protected void onPostExecute(String resultado) {
    super.onPostExecute(resultado);
    //procesa el html resultante de la peticin httpGet
    try {/*from  w w w .j  a va2 s.  c om*/
        procesa(resultado);
        Estaticos.ringProgressDialog.dismiss();
    } catch (Exception e) {
        Toast.makeText(context, context.getString(R.string.error_sesion), Toast.LENGTH_LONG).show();
        try {
            finalize();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
    }

}

From source file:pl.bcichecki.rms.client.android.fragments.UsersListFragment.java

private void downloadData() {
    Log.d(TAG, "Downloading users list...");

    if (!AppUtils.checkInternetConnection(getActivity())) {
        Log.d(TAG, "There is NO network connected!");
        return;/* w w w . ja  v  a2  s .c  om*/
    }

    usersRestClient.getAllUsers(new GsonHttpResponseHandler<List<User>>(new TypeToken<List<User>>() {
    }.getType(), true) {

        @Override
        public void onFailure(Throwable error, String content) {
            Log.d(TAG, "Retrieving users failed. [error=" + error + ", content=" + content + "]");
            if (error instanceof HttpResponseException) {
                if (((HttpResponseException) error).getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
                    AppUtils.showCenteredToast(getActivity(), R.string.general_unathorized_error_message_title,
                            Toast.LENGTH_LONG);
                } else {
                    AppUtils.showCenteredToast(getActivity(), R.string.general_unknown_error_message_title,
                            Toast.LENGTH_LONG);
                }
            } else {
                AppUtils.showCenteredToast(getActivity(), R.string.general_unknown_error_message_title,
                        Toast.LENGTH_LONG);
            }
        }

        @Override
        public void onFinish() {
            usersListAdapter.refresh();
            hideLoadingMessage();
            Log.d(TAG, "Retrieving users finished.");
        }

        @Override
        public void onStart() {
            Log.d(TAG, "Retrieving users started.");
            showLoadingMessage();
            users.clear();
        }

        @Override
        public void onSuccess(int statusCode, List<User> object) {
            Log.d(TAG, "Retrieving users successful. Retrieved " + object.size() + " objects.");
            users.addAll(object);
        }
    });
}

From source file:es.warp.desktop_droid.TelephonyEventService.java

@Override
public void onDestroy() {
    Toast.makeText(this, "My Service Stopped", Toast.LENGTH_LONG);
    Log.d("TelephonyEventService", "onDestroy");
    TelephonyManager manager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    manager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
}

From source file:com.wso2.mobile.mdm.services.WSO2DeviceAdminReceiver.java

/** Called when this application is no longer the device administrator. */
@Override//from   w w  w.  ja  v  a 2  s .co  m
public void onDisabled(Context context, Intent intent) {
    super.onDisabled(context, intent);
    Toast.makeText(context, R.string.device_admin_disabled, Toast.LENGTH_LONG).show();
    Log.d(TAG, "onDisabled");
    if (regId == null || regId.equals("")) {
        regId = GCMRegistrar.getRegistrationId(context);
    }

    if (regId != null || !regId.equals("")) {
        startUnRegistration(context);
    }

}