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:com.example.zillowapplication.SlidingTabsBasicFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    try {/*from   w w w . j ava2  s  .c om*/
        Session.getActiveSession().onActivityResult(this.getActivity(), requestCode, resultCode, data);
        uiHelper.onActivityResult(requestCode, resultCode, data, new FacebookDialog.Callback() {

            @Override
            public void onError(FacebookDialog.PendingCall pendingCall, Exception error, Bundle data) {
                Log.e("Activity", String.format("Error: %s", error.toString()));
            }

            @Override
            public void onComplete(FacebookDialog.PendingCall pendingCall, Bundle data) {

                String postid = FacebookDialog.getNativeDialogCompletionGesture(data);
                if (postid != null && !postid.equals("post")) {
                    Toast toast = Toast.makeText(getActivity(), "Post Cancelled", Toast.LENGTH_SHORT);
                    toast.show();

                    /*Random r = new Random();
                    long n = 100000 + Math.abs(r.nextLong()*99999);
                    long n1 = 100000 + Math.abs(r.nextLong() * 99999);
                    String nL="86709"+Long.toString(n1)+"6079";
                    String np="100001"+Long.toString(n)+"035";
                    //100001035
                    String postId = "Your post id is "+np+"_"+nL;// 100001035901206_384361345941672";//+FacebookDialog.getNativeDialogPostId(data);
                    Toast toast = Toast.makeText(getActivity(), postId, Toast.LENGTH_SHORT);
                    toast.show();*/
                }
                Log.i("Activity", "Success!");
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.zia.freshdocs.widget.CMISAdapter.java

/**
 * Send the content using a built-in Android activity which can handle the content type.
 * @param position/*from w  ww. ja va2 s .c om*/
 */
public void shareContent(int position) {
    final NodeRef ref = getItem(position);
    downloadContent(ref, new Handler() {
        public void handleMessage(Message msg) {
            Context context = getContext();
            boolean done = msg.getData().getBoolean("done");

            if (done) {
                dismissProgressDlg();

                File file = (File) _dlThread.getResult();

                if (file != null) {
                    Resources res = context.getResources();
                    Uri uri = Uri.fromFile(file);
                    Intent emailIntent = new Intent(Intent.ACTION_SEND);
                    emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
                    emailIntent.putExtra(Intent.EXTRA_SUBJECT, ref.getName());
                    emailIntent.putExtra(Intent.EXTRA_TEXT, res.getString(R.string.email_text));
                    emailIntent.setType(ref.getContentType());

                    try {
                        context.startActivity(
                                Intent.createChooser(emailIntent, res.getString(R.string.email_title)));
                    } catch (ActivityNotFoundException e) {
                        String text = "No suitable applications registered to send " + ref.getContentType();
                        int duration = Toast.LENGTH_SHORT;
                        Toast toast = Toast.makeText(context, text, duration);
                        toast.show();
                    }
                }
            } else {
                int value = msg.getData().getInt("progress");
                if (value > 0) {
                    _progressDlg.setProgress(value);
                }
            }
        }
    });
}

From source file:org.ewicom.pps.unitinfo.TabAddressFragment.java

public void openUnitOnMap() {
    String latitude = unit.getLatitude();
    String longitude = unit.getLongitude();

    Context context = getActivity().getApplicationContext();
    Toast noGeotoast = Toast.makeText(context, R.string.empty_geodata, Toast.LENGTH_SHORT);
    Toast noAppMap = Toast.makeText(context, R.string.no_map_app, Toast.LENGTH_LONG);

    if (StringUtils.isEmpty(latitude)) {
        noGeotoast.show();
    } else {//w  w w .ja  v  a 2 s .c om
        String geoUri = "geo:" + latitude + "," + longitude + "?q=" + latitude + "," + longitude;
        Intent showUnitOnMapIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(geoUri));
        showUnitOnMapIntent.setComponent(
                new ComponentName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"));

        if (PPSAddressBook.isIntentAvailable(getActivity(), showUnitOnMapIntent)) {
            startActivity(showUnitOnMapIntent);
        } else {
            noAppMap.show();
        }

    }
}

From source file:it.readbeyond.minstrel.commander.Commander.java

private void toast(final String msg, final CallbackContext callbackContext) {
    cordova.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            Toast toast = Toast.makeText(cordova.getActivity().getApplicationContext(), msg, Toast.LENGTH_LONG);
            toast.show();
            callbackContext.success("");
        }//from  w w  w. j a  va  2  s . c  o  m
    });
}

From source file:com.uproot.trackme.LocationActivity.java

public void Toast(String s, int Xoff, int Yoff) {
    Context context = getApplicationContext();
    CharSequence text = s;/*from   ww  w.  ja v a  2 s .  c  o m*/
    int duration = Toast.LENGTH_LONG;
    Toast toast = Toast.makeText(context, text, duration);
    toast.setGravity(Gravity.TOP | Gravity.LEFT, Xoff, Yoff);
    toast.show();
}

From source file:com.anjalimacwan.fragment.NoteViewFragment.java

private void showToastLong(int message) {
    Toast toast = Toast.makeText(getActivity(), getResources().getString(message), Toast.LENGTH_LONG);
    toast.show();
}

From source file:fr.pasteque.client.Configure.java

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    if (preference.getKey().equals("printer_driver")) {
        // On printer driver update, change models
        if (newValue.equals("EPSON ePOS") && !Compat.isEpsonPrinterCompatible()) {
            Toast t = Toast.makeText(this, R.string.not_compatible, Toast.LENGTH_SHORT);
            t.show();
            return false;
        } else if ((newValue.equals("LK-PXX") && !Compat.isLKPXXPrinterCompatible())
                || (newValue.equals("Woosim") && !Compat.isWoosimPrinterCompatible())) {
            Toast t = Toast.makeText(this, R.string.not_compatible, Toast.LENGTH_SHORT);
            t.show();/*from   w  w w . j a  v  a  2  s. c  om*/
            return false;
        }
        this.updatePrinterPrefs(newValue);
    } else if ("card_processor".equals(preference.getKey())) {
        if ("payleven".equals(newValue) && !Compat.hasPaylevenApp(this)) {
            // Trying to enable payleven without app: download
            AlertDialog.Builder b = new AlertDialog.Builder(this);
            b.setTitle(R.string.config_payleven_download_title);
            b.setMessage(R.string.config_payleven_download_message);
            b.setIcon(android.R.drawable.ic_dialog_info);
            b.setNegativeButton(android.R.string.cancel, null);
            b.setPositiveButton(R.string.config_payleven_download_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    Intent i = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("market://details?id=de.payleven.androidphone"));
                    Configure.this.startActivity(i);
                }
            });
            b.show();
            return false;
        }
        this.updateCardProcessorPreferences((String) newValue);
    }
    return true;
}

From source file:com.akop.bach.fragment.playstation.TrophiesFragment.java

private void showTrophyDetails(CharSequence title, CharSequence description) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View layout = inflater.inflate(R.layout.psn_trophy_toast,
            (ViewGroup) getActivity().findViewById(R.id.toast_root));

    TextView text = (TextView) layout.findViewById(R.id.trophy_title);
    text.setText(title);//from w  ww  . ja  v a2 s .c o  m
    text = (TextView) layout.findViewById(R.id.trophy_description);
    text.setText(description);

    Toast toast = new Toast(getActivity());
    toast.setDuration(Toast.LENGTH_LONG);
    toast.setView(layout);

    toast.show();
}

From source file:com.ichi2.anki.ModelBrowser.java

private void showToast(CharSequence text) {
    int duration = Toast.LENGTH_SHORT;
    Toast toast = Toast.makeText(this, text, duration);
    toast.show();
}

From source file:net.stefanopallicca.android.awsmonitor.MainActivity.java

public void launchMainApp() {
    setContentView(R.layout.main);/*from w  w w .j a va  2s . c o  m*/
    //mDisplay = (TextView) findViewById(R.id.display);

    context = getApplicationContext();

    /* 
     * Check device for Play Services APK. 
     * If check succeeds, proceed with GSN server registration and download available virtual sensors.
     */
    if (checkPlayServices()) {
        gcm = GoogleCloudMessaging.getInstance(this);
        regid = getRegistrationId(context);
        server = new GsnServer(_sharedPref.getString("pref_server_url", ""),
                Integer.parseInt(_sharedPref.getString("pref_server_port", "")));

        /*if (regid.isEmpty()) {
            registerInBackground();
        }
        else {
           Log.i(TAG, "This version has already been registered to GCM "+regid);
        }*/
        boolean registered_to_gsnserver = false;
        try {
            registered_to_gsnserver = server.checkDeviceRegistration(regid);
            if (!registered_to_gsnserver)
                registered_to_gsnserver = server.sendRegistrationIdToBackend(regid);
        } catch (ConnectTimeoutException e) {
            int duration = Toast.LENGTH_LONG;

            Toast toast = Toast.makeText(context,
                    getString(R.string.connect_timeout) + " " + server.getURL() + ":" + server.getPort(),
                    duration);
            toast.show();
        } catch (HttpException e) {
            int duration = Toast.LENGTH_LONG;

            Toast toast = Toast.makeText(context, getString(R.string.service_not_found), duration);
            toast.show();
        }
        if (!regid.isEmpty() && registered_to_gsnserver) {
            Log.i(TAG, "This device has been registered to GSN server");
            //mDisplay.append("Device ready to receive notifications from GSN server " + _sharedPref.getString("pref_server_url", ""));
            server.getSummary();
            setContentView(R.layout.main);
            ListView listView = getListView();
            mDisplay = (TextView) findViewById(R.id.main_header);
            mDisplay.append(server.getName());
            List<VirtualSensor> list = new LinkedList<VirtualSensor>();
            for (int i = 0; i < server.virtualSensors.size(); i++) {
                // only add virtual sensors with fields to list (skip app-generated virtual sensors)
                if (server.virtualSensors.get(i).getNumFields() > 0)
                    list.add(server.virtualSensors.get(i));
            }
            VirtualSensorListAdapter adapter = new VirtualSensorListAdapter(this, R.layout.vs_row, list);
            listView.setAdapter(adapter);

        } else {
            //mDisplay.append("This device is not ready to receive notifications from a GSN server. Go to settings to configure a GSN server");
        }
    } else {
        Log.i(TAG, "No valid Google Play Services APK found.");
    }
}