Example usage for android.widget Toast show

List of usage examples for android.widget Toast show

Introduction

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

Prototype

public void show() 

Source Link

Document

Show the view for the specified duration.

Usage

From source file:org.openplans.rcavl.RCAVL.java

public void toast(final String text) {
    runOnUiThread(new Runnable() {
        public void run() {
            Context context = getApplicationContext();
            int duration = Toast.LENGTH_SHORT;

            Toast toast = Toast.makeText(context, text, duration);
            toast.show();
        }/*w  ww  .  ja v a2s  .co m*/
    });
}

From source file:com.github.wakhub.monodict.activity.bean.ActivityHelper.java

@UiThread
public void showToastLong(String message) {
    Toast toast = Toast.makeText(activity.getApplicationContext(), message, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.BOTTOM, 0, 0);
    toast.show();
}

From source file:net.gromgull.android.bibsonomyposter.BibsonomyPosterActivity.java

private void save() {
    SharedPreferences p = getSharedPreferences(PREF_NAME, 0);
    Editor e = p.edit();/*  w  ww.  j  ava2 s . c o m*/

    e.putString(PREF_USERNAME, getUsername());
    e.putString(PREF_APIKEY, getAPIKey());

    e.commit();

    Toast toast = Toast.makeText(getApplicationContext(), "Saved username/apikey - now go bookmark something!",
            Toast.LENGTH_SHORT);
    toast.show();

    finish();

}

From source file:com.github.wakhub.monodict.activity.bean.ActivityHelper.java

@UiThread
public void showToast(String message) {
    Toast toast = Toast.makeText(activity.getApplicationContext(), message, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.BOTTOM, 0, 0);
    toast.show();
}

From source file:org.sigimera.app.android.GCMIntentService.java

@Override
protected final void onUnregistered(final Context context, String regID) {
    final String HOST = Config.getInstance().getAPIHost() + "/gcm";
    HttpClient httpclient = new MyHttpClient(ApplicationController.getInstance().getApplicationContext());
    try {/*from ww w.  j a  v  a  2  s. c o  m*/
        String authToken = SessionHandler.getInstance(null).getAuthenticationToken();
        final String toastMessage;
        if (regID != null && !regID.equals("")) {
            HttpDelete request = new HttpDelete(HOST + "/" + regID + "?auth_token=" + authToken);
            httpclient.execute(request);
            toastMessage = "Successfully unregistered!";
        } else {
            toastMessage = "You are not registered to receive push notifications.";
        }
        this.mainThreadHandler.post(new Runnable() {
            public void run() {
                Toast toast = Toast.makeText(getApplicationContext(), toastMessage, Toast.LENGTH_LONG);
                toast.setGravity(Gravity.TOP, 0, 0);
                toast.show();
            }
        });
    } catch (AuthenticationErrorException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        httpclient.getConnectionManager().shutdown();
    }
}

From source file:be.vbsteven.bmtodesk.ShareActivity.java

/**
 * handles the result of the POST request
 *
 * @param message//from  w ww . j  a  v  a 2s.  c o  m
 */
private void onResult(String message) {

    if (message == null) {
        Utils.showMessage(this, "Sending bookmark failed",
                "Please try again later or contact me on twitter: @vbsteven");
        return;
    }

    if (message.startsWith("INVALIDENTRY")) {
        Utils.showMessage(this, "Invalid input", "Please provide a title and a url");
        return;
    }

    if (message.startsWith("INVALIDLOGIN")) {
        Utils.showMessage(this, "Authentication failed", "Please check your account info in preferences");
        return;
    }

    if (message.startsWith("SUCCESSFUL")) {
        if (Global.isHideConfirmation(this)) {
            Toast t = Toast.makeText(this, "Bookmark sent to server!", Toast.LENGTH_SHORT);
            t.show();
        } else {
            String title = ((EditText) findViewById(R.id.et_title)).getText().toString();
            String url = ((EditText) findViewById(R.id.et_url)).getText().toString();

            Intent intent = new Intent(this, AfterSuccessfulSendActivity.class);
            intent.putExtra(Global.EXTRA_TITLE, title);
            intent.putExtra(Global.EXTRA_URL, url);

            startActivity(intent);
        }
        finish();
        return;
    }

    Utils.showMessage(this, "Sending bookmark failed",
            "Please try again later or contact me on twitter @vbsteven");
}

From source file:com.digitalarx.android.files.FileOperationsHelper.java

public void unshareFileWithLink(OCFile file) {

    if (isSharedSupported()) {
        // Unshare the file
        Intent service = new Intent(mFileActivity, OperationsService.class);
        service.setAction(OperationsService.ACTION_UNSHARE);
        service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
        service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
        mWaitingForOpId = mFileActivity.getOperationsServiceBinder().newOperation(service);

        mFileActivity.showLoadingDialog();

    } else {/*from  ww  w.j a va  2  s  . c o  m*/
        // Show a Message
        Toast t = Toast.makeText(mFileActivity,
                mFileActivity.getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG);
        t.show();

    }
}

From source file:be.vbsteven.bmtodesk.RegistrationActivity.java

/**
 * shows a successful message to the user
 *
 * @param message//from ww  w  . j a  v  a 2 s  .  c o m
 */
private void showSuccessfulMessage(String message) {
    Toast t = Toast.makeText(this, message, Toast.LENGTH_LONG);
    t.show();
}

From source file:com.digitalarx.android.files.FileOperationsHelper.java

public void shareFileWithLink(OCFile file) {

    if (isSharedSupported()) {
        if (file != null) {
            String link = "https://fake.url";
            Intent intent = createShareWithLinkIntent(link);
            String[] packagesToExclude = new String[] { mFileActivity.getPackageName() };
            DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intent, packagesToExclude, file);
            chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);

        } else {/*from www.j  a va 2 s  .  c om*/
            Log_OC.wtf(TAG, "Trying to share a NULL OCFile");
        }

    } else {
        // Show a Message
        Toast t = Toast.makeText(mFileActivity,
                mFileActivity.getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG);
        t.show();
    }
}

From source file:it.unipr.ce.dsg.s2p.example.peerdroid.SimplePeer.java

@Override
protected void onReceivedJSONMsg(JSONObject jsonMsg, Address sender) {

    try {// w w w  . ja v a2s.  c om

        JSONObject params = jsonMsg.getJSONObject("payload").getJSONObject("params");

        if (jsonMsg.get("type").equals(PeerListMessage.MSG_PEER_LIST)) {

            PeerActivity.handler.post(new Runnable() {
                public void run() {
                    Toast toast = Toast.makeText(peerActivity.getBaseContext(),
                            "Received: " + PeerListMessage.MSG_PEER_LIST, Toast.LENGTH_LONG);
                    toast.show();
                }
            });

            Iterator<String> iter = params.keys();

            while (iter.hasNext()) {

                String key = (String) iter.next();

                JSONObject keyPeer = params.getJSONObject(key);
                PeerDescriptor neighborPeerDesc = new PeerDescriptor(keyPeer.get("name").toString(),
                        keyPeer.get("address").toString(), keyPeer.get("key").toString());

                if (keyPeer.get("contactAddress").toString() != "null")
                    neighborPeerDesc.setContactAddress(keyPeer.get("contactAddress").toString());

                addNeighborPeer(neighborPeerDesc);

                Integer size = new Integer(this.peerList.size());

            }

        }
        if (jsonMsg.get("type").equals(PingMessage.MSG_PEER_PING)) {
            PeerActivity.handler.post(new Runnable() {
                public void run() {
                    Toast toast = Toast.makeText(peerActivity.getBaseContext(),
                            "Received: " + PingMessage.MSG_PEER_PING, Toast.LENGTH_LONG);
                    toast.show();
                }
            });

            PeerDescriptor neighborPeerDesc = new PeerDescriptor(params.get("name").toString(),
                    params.get("address").toString(), params.get("key").toString(),
                    params.get("contactAddress").toString());
            addNeighborPeer(neighborPeerDesc);

        }

    } catch (JSONException e) {

        e.printStackTrace();
    }

}