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:cz.msebera.unbound.dns.fragments.MainLogFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_EMPTY:
        try {//  w  ww  .  j a v  a2 s  .c o  m
            FileWriter fw = new FileWriter(
                    new File(getActivity().getFilesDir(), getString(R.string.path_mainlog)), false);
            fw.write("");
            fw.close();
            Toast.makeText(getActivity(), R.string.configuration_saved, Toast.LENGTH_LONG).show();
        } catch (IOException e) {
            Log.e(TAG, getString(R.string.error_cannot_write_unbound_conf), e);
        }
    case MENU_CLEAR:
        mTextArea.setText("");
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.wikitude.example.CopyOfSimpleARBrowserActivity.java

/** Called when the activity is first created. */
@Override/* w  ww . j  a va2 s .co m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //let the application be fullscreen
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    //check if the device fulfills the SDK'S minimum requirements
    if (!ArchitectView.isDeviceSupported(this)) {
        Toast.makeText(this, "minimum requirements not fulfilled", Toast.LENGTH_LONG).show();
        this.finish();
        return;
    }
    setContentView(R.layout.main);

    //set the devices' volume control to music to be able to change the volume of possible soundfiles to play
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
    this.architectView = (ArchitectView) this.findViewById(R.id.architectView);
    //onCreate method for setting the license key for the SDK
    architectView.onCreate(apiKey);

    //in order to inform the ARchitect framework about the user's location Androids LocationManager is used in this case
    //NOT USED IN THIS EXAMPLE
    //locManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
    //locManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, this);
}

From source file:jp.co.anaheim_eng.aessample.MainActivity.java

@Override
public void onClick(View v) {
    byte[] bytes;

    try {/*from w w  w.j  ava 2s  . com*/
        switch (v.getId()) {
        case R.id.btn_encode: {
            if (getPreferences() == false) {
                Intent intent = new Intent(this, MainPreferenceActivity.class);
                startActivity(intent);
                return;
            }
            // Create AES Library object
            AESLib al = new AESLib(mKeyBitLen, mPassword, mSalt);
            al.setPlainText(mPlainText);
            al.Encode();
            // Encode result
            mCiphers = al.getCiphers();
            StringBuilder sb = new StringBuilder();
            sb.append("AES Encode result [" + String.valueOf(mKeyBitLen) + "bit]\n");
            for (int i = 0; i < 3; i++) {
                sb.append("No." + String.valueOf(i + 1) + "\n");
                sb.append("Plain Text:" + mPlainText.get(i) + "\n");
                bytes = mCiphers.get(i);
                sb.append("Cipher    :" + String.valueOf(Hex.encodeHex(bytes)) + "\n");
            }
            TextView tv = (TextView) findViewById(R.id.textView1);
            tv.setText(sb);
            break;
        }
        case R.id.btn_decode: {
            if ((mCiphers == null) || (mCiphers.size() == 0)) {
                Toast.makeText(this, R.string.err_nonecipher, Toast.LENGTH_LONG).show();
                return;
            }
            // Create AES Library object
            AESLib al = new AESLib(mKeyBitLen, mPassword, mSalt);
            al.setCiphers(mCiphers);
            al.Decode();
            // Decode result
            mPlainText = al.getPlainText();
            StringBuilder sb = new StringBuilder();
            sb.append("AES Decode result [" + String.valueOf(mKeyBitLen) + "bit]\n");
            for (int i = 0; i < 3; i++) {
                sb.append("No." + String.valueOf(i + 1) + "\n");
                bytes = mCiphers.get(i);
                sb.append("Cipher    :" + String.valueOf(Hex.encodeHex(bytes)) + "\n");
                sb.append("Plain Text:" + mPlainText.get(i) + "\n");
            }
            TextView tv = (TextView) findViewById(R.id.textView1);
            tv.setText(sb);
            break;
        }
        case R.id.btn_pref: {
            Intent intent = new Intent(this, MainPreferenceActivity.class);
            startActivity(intent);
            break;
        }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:cn.ttyhuo.activity.InfoOwnerActivity.java

@Override
protected void initView() {
    super.initView();

    mEditDate = (TextView) findViewById(R.id.edit_date);
    mEditChexing = (TextView) findViewById(R.id.edit_chexing);

    mEditZaizhong = (EditText) findViewById(R.id.edit_zaizhong);
    mEditChechang = (EditText) findViewById(R.id.edit_chechang);
    mEditZuowei = (EditText) findViewById(R.id.edit_zuowei);
    mEditChepai = (EditText) findViewById(R.id.edit_chepaihao);
    mEditXinghao = (EditText) findViewById(R.id.edit_xinghao);
    mEditKuan = (EditText) findViewById(R.id.edit_kuan);
    mEditGao = (EditText) findViewById(R.id.edit_gao);
    tv_edit_tips = (TextView) findViewById(R.id.tv_edit_tips);

    // //from  w  w w . j  av a2 s.  com
    mEditZaizhong.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            String numStr = v.getText().toString();
            if (!StringNumberUtils.isPositiveDecimal(numStr) && !StringNumberUtils.isPositiveInteger(numStr)) {
                Toast.makeText(mContext, "1.0-100.0", Toast.LENGTH_SHORT).show();
            } else {
                float num = Float.parseFloat(numStr);
                if (num > 10.0 || num < 1.0) {
                    Toast.makeText(mContext, "1.0-100.0", Toast.LENGTH_SHORT).show();
                }
            }
            return false;
        }
    });

    progressBar = (ProgressBar) findViewById(R.id.progressBar1);
    if (progressBar != null)
        progressBar.setVisibility(View.VISIBLE);
    isDoingUpdate = true;
    if (!NetworkUtils.isNetworkAvailable(mContext)) {
        Toast.makeText(mContext, "??", Toast.LENGTH_LONG).show();
    }
    new UrlThread(handler, UrlList.MAIN + "mvc/editTruckInfoJson".toString(), 1).start();
}

From source file:bbw.com.crashr.HeatmapsDemoActivity.java

private void updateMap() {

    List<Incident> incidents = IncidentHelper.getInstance(this).getIncidents();
    if (incidents == null)
        return;//  ww w .ja  v a 2s . co  m

    try {
        //mLists.put("crashes", new DataSet(readItems(R.raw.tmp)));
        mLists.put("crashes", new DataSet(readIncidents(incidents)));
    } catch (Exception e) {
        Toast.makeText(this, "Problem reading list of markers.", Toast.LENGTH_LONG).show();
    }

    if (mLists.get("crashes").getData().size() != 0) {
        if (mProvider == null) {
            mProvider = new HeatmapTileProvider.Builder().data(mLists.get("crashes").getData()).build();
            mProvider.setRadius(RADIUS);
            mProvider.setOpacity(OPACITY);
            mOverlay = getMap().addTileOverlay(new TileOverlayOptions().tileProvider(mProvider));
        } else {
            mProvider.setData(mLists.get("crashes").getData());
            mOverlay.clearTileCache();
        }
    }

    // ok now move the map to the user's current location
    Location loc = IncidentHelper.getInstance(this).getLocation();
    if (loc != null) {
        LatLng coordinate = new LatLng(loc.getLatitude(), loc.getLongitude());
        CameraUpdate update = CameraUpdateFactory.newLatLngZoom(coordinate, getMap().getCameraPosition().zoom);
        getMap().moveCamera(update);
    }
    // do the right zoom

}

From source file:com.manning.androidhacks.hack040.util.ImageFetcher.java

/**
 * Simple network connection check./*from   w  ww. j  av a 2s  .  co  m*/
 * 
 * @param context
 */
private void checkConnection(Context context) {
    final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo networkInfo = cm.getActiveNetworkInfo();
    if (networkInfo == null || !networkInfo.isConnectedOrConnecting()) {
        Toast.makeText(context, "No network connection found.", Toast.LENGTH_LONG).show();
        Log.e(TAG, "checkConnection - no connection found");
    }
}

From source file:it_minds.dk.eindberetningmobil_android.views.MissingTripActivity.java

private void trySend(final SaveableReport report) {
    SaveableDriveReport driveReport = new SaveableDriveReport(
            MainSettings.getInstance(this).getProfile().getAuthorization(), report);
    ServerFactory.getInstance(this).sendSavedReport(driveReport, new ResultCallback<JSONObject>() {
        @Override/*  www  .j a va 2 s  . c  o m*/
        public void onSuccess(JSONObject result) {
            MainSettings.getInstance(MissingTripActivity.this).removeSavedReport(report);
            Toast.makeText(MissingTripActivity.this, R.string.send_and_recived, Toast.LENGTH_SHORT).show();
            refreshData();
        }

        @Override
        public void onError(Exception error) {
            Toast.makeText(MissingTripActivity.this, R.string.error_sending_retry_later, Toast.LENGTH_LONG)
                    .show();
        }
    });
}

From source file:app.com.example.android.sunshine.ForecastFragment.java

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

    // Create some dummy data for the ListView.  Here's a sample weekly forecast
    String[] data = { "Mon 6/23- Sunny - 31/17", "Tue 6/24 - Foggy - 21/8", "Wed 6/25 - Cloudy - 22/17",
            "Thurs 6/26 - Rainy - 18/11", "Fri 6/27 - Foggy - 21/10",
            "Sat 6/28 - TRAPPED IN WEATHER STATION - 23/18", "Sun 6/29 - Sunny - 20/7" };
    List<String> weekForecast = new ArrayList<String>(Arrays.asList(data));

    // Now that we have some dummy forecast data, create an ArrayAdapter.
    // The ArrayAdapter will take data from a source (like our dummy forecast) and
    // use it to populate the ListView it's attached to.
    forecastAdapter = new ArrayAdapter<String>(getActivity(), // The current context (this activity)
            R.layout.list_item_forecast, // The name of the layout ID.
            R.id.list_item_forecast_textview, // The ID of the textview to populate.
            weekForecast);/*from   ww  w. j a  v a  2 s .  c o  m*/

    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    // Get a reference to the ListView, and attach this adapter to it.
    ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast);
    listView.setAdapter(forecastAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            Toast.makeText(getActivity(), forecastAdapter.getItem(position), Toast.LENGTH_LONG).show();
            Intent detailIntent = new Intent(getActivity(), DetailActivity.class);
            detailIntent.putExtra(Intent.EXTRA_TEXT, forecastAdapter.getItem(position));
            startActivity(detailIntent);

        }
    });
    return rootView;
}

From source file:com.piggate.samples.PiggateLogin.Activity_SingUp.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    _piggate = new Piggate(this, null); //Initialize the Piggate object

    setContentView(R.layout.activity_register);
    //EditTexts for user email and password
    editEmail = (EditText) findViewById(R.id.editText1);
    editPass = (EditText) findViewById(R.id.editText2);
    final ImageButton return_button = (ImageButton) findViewById(R.id.return1);
    Button register = (Button) findViewById(R.id.buttonregister2);

    //Handles the top left back button of the activity
    return_button.setOnClickListener(new View.OnClickListener() {
        @Override//from www .j a v  a 2s.c o  m
        public void onClick(View v) {
            onBackPressed();
        }
    });

    //OnClick listener for the login button
    //Handles the login request to the server with the email and password fields
    register.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {
            if (!handledClick) {
                handledClick = true;
                String email = editEmail.getText().toString();
                String pass = editPass.getText().toString();

                //If the internet connection is working
                if (checkInternetConnection() == true) {
                    RequestParams params = new RequestParams();
                    params.put("email", email);
                    params.put("password", pass);

                    //Request of the Piggate object. Handles the login into the application with the user email and password
                    _piggate.RequestNewUser(params).setListenerRequest(new Piggate.PiggateCallBack() {

                        //Method onComplete for JSONObject
                        //When the request is correct start Activity_Logged activity
                        @Override
                        public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {
                            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                            Intent slideactivity = new Intent(Activity_SingUp.this, Activity_Logged.class);
                            Bundle bndlanimation = ActivityOptions
                                    .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2)
                                    .toBundle();
                            startActivity(slideactivity, bndlanimation);
                        }

                        //Method onError for JSONObject
                        //If there's an error with the request displays the error message to the user
                        @Override
                        public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                        }

                        //Method onComplete for JSONArray
                        @Override
                        public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) {
                            //Unused
                        }

                        //Method onError for JSONArray
                        @Override
                        public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                            //Unused
                        }
                    }).exec();
                } else { //If the internet connection is not working
                    Toast.makeText(getApplicationContext(), "Network is not working", Toast.LENGTH_LONG).show();
                }
            }
        }
    });
}

From source file:com.piggate.samples.PiggateLoginApplication.Activity_SingIn.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    _piggate = new Piggate(this, null); //Initialize the Piggate object

    setContentView(R.layout.activity_login);
    //EditTexts for user email and password
    editEmail = (EditText) findViewById(R.id.editText1);
    editPass = (EditText) findViewById(R.id.editText2);
    Button login = (Button) findViewById(R.id.buttonlogin2);
    final ImageButton return_button = (ImageButton) findViewById(R.id.return1);

    //Handles the top left back button of the activity
    return_button.setOnClickListener(new View.OnClickListener() {
        @Override// ww  w.  ja va 2  s .c o m
        public void onClick(View v) {
            onBackPressed();
        }
    });

    //OnClick listener for the login button
    //Handles the login request to the server with the email and password fields
    login.setOnClickListener(new View.OnClickListener() {
        @Override
        synchronized public void onClick(View v) {
            if (!handledClick) {
                handledClick = true;
                String email = editEmail.getText().toString();
                String pass = editPass.getText().toString();

                //If the internet connection is working
                if (checkInternetConnection() == true) {
                    RequestParams params = new RequestParams();
                    params.put("email", email);
                    params.put("password", pass);

                    //Request of the Piggate object. Handles the login into the application with the user email and password
                    _piggate.RequestOpenSession(params).setListenerRequest(new Piggate.PiggateCallBack() {

                        //Method onComplete for JSONObject
                        //When the request is correct start Activity_Logged activity
                        @Override
                        public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {
                            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                            Intent slideactivity = new Intent(Activity_SingIn.this, Activity_Logged.class);
                            Bundle bndlanimation = ActivityOptions
                                    .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2)
                                    .toBundle();
                            startActivity(slideactivity, bndlanimation);
                        }

                        //Method onError for JSONObject
                        //If there's an error with the request displays the error message to the user
                        @Override
                        public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                            handledClick = false;

                        }

                        //Method onComplete for JSONArray
                        @Override
                        public void onComplete(int statusCode, Header[] headers, String msg, JSONArray data) {
                            //Unused
                        }

                        //Method onError for JSONArray
                        @Override
                        public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                            //Unused
                        }
                    }).exec();
                } else { //If the internet connection is not working
                    Toast.makeText(getApplicationContext(), "Network is not working", Toast.LENGTH_LONG).show();
                    handledClick = false;

                }
            }
        }
    });
}