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:MainActivity.java

public void readFile(View view) {
    if (isExternalStorageReadable()) {
        StringBuilder stringBuilder = new StringBuilder();
        try {/* ww  w .jav  a  2 s  .  c  o  m*/
            File textFile = new File(Environment.getExternalStorageDirectory(), FILENAME);
            FileInputStream fileInputStream = new FileInputStream(textFile);
            if (fileInputStream != null) {
                InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
                BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
                String newLine = null;
                while ((newLine = bufferedReader.readLine()) != null) {
                    stringBuilder.append(newLine + "\n");
                }
                fileInputStream.close();
            }
            mEditText.setText(stringBuilder);
        } catch (java.io.IOException e) {
            e.printStackTrace();
            Toast.makeText(this, "Error reading file", Toast.LENGTH_LONG).show();
        }
    } else {
        Toast.makeText(this, "Cannot read External Storage", Toast.LENGTH_LONG).show();
    }
}

From source file:fi.mikuz.boarder.gui.ZipImporter.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.zip_importer);
    mInfoText = (TextView) findViewById(R.id.infoText);
    mInfoText.setText("Please wait");

    if (getIntent().getData() != null && getIntent().getData().getPath() != null) {
        unzipArchive(new File(getIntent().getData().getPath()), SoundboardMenu.mSbDir);
    } else {/*from  w  w w  .j  a  va2 s.c  om*/
        String msg = "Invalid file path";
        Log.e(TAG, msg);
        Toast.makeText(super.mContext, msg, Toast.LENGTH_LONG).show();
    }
}

From source file:org.messic.android.controllers.LoginController.java

public void login(final Activity context, final boolean remember, final String username, final String password,
        final ProgressDialog pd) throws Exception {
    Network.nukeNetwork();/*www .  j  a  va2s.c  o m*/

    final String baseURL = Configuration.getBaseUrl() + "/messiclogin";
    MultiValueMap<String, Object> formData = new LinkedMultiValueMap<String, Object>();
    formData.add("j_username", username);
    formData.add("j_password", password);
    try {
        RestJSONClient.post(baseURL, formData, MDMLogin.class, new RestJSONClient.RestListener<MDMLogin>() {
            public void response(MDMLogin response) {
                MessicPreferences mp = new MessicPreferences(context);
                mp.setRemember(remember, username, password);
                Configuration.setToken(response.getMessic_token());

                pd.dismiss();
                Intent ssa = new Intent(context, BaseActivity.class);
                context.startActivity(ssa);
            }

            public void fail(Exception e) {
                Log.e("Login", e.getMessage(), e);
                context.runOnUiThread(new Runnable() {
                    public void run() {
                        pd.dismiss();
                        Toast.makeText(context, "Error", Toast.LENGTH_LONG).show();
                    }
                });

            }
        });
    } catch (Exception e) {
        pd.dismiss();
        Log.e("login", e.getMessage(), e);
        throw e;
    }
}

From source file:com.wolkabout.hexiwear.activity.SignUpActivity.java

@Click(R.id.signUpButton)
void signUp() {//from   www.j  ava 2  s  .com
    if (!validate()) {
        return;
    }

    if (!termsAndConditions.isChecked()) {
        Toast.makeText(this, R.string.registration_accept_terms, Toast.LENGTH_LONG).show();
        return;
    }

    signUpButton.setEnabled(false);
    signingUp.setVisibility(View.VISIBLE);
    startSignUp();
}

From source file:com.iternox.piggate.samples.PiggateLogin.Activity_SingIn.java

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

    setContentView(R.layout.activity_login);
    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);
    return_button.setOnClickListener(new View.OnClickListener() {
        @Override//from  w  w w.j  a  v a2  s . co  m
        public void onClick(View v) {
            onBackPressed();
        }
    });
    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 (checkInternetConnection() == true) {
                    RequestParams params = new RequestParams();
                    params.put("email", email);
                    params.put("password", pass);
                    _piggate.RequestOpenSession(params).setListenerRequest(new Piggate.PiggateCallBack() {
                        @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);
                        }

                        @Override
                        public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                            handledClick = false;

                        }

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

                        @Override
                        public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                            //Unused
                        }
                    }).exec();

                } else {
                    Toast.makeText(getApplicationContext(), "Network is not working", Toast.LENGTH_LONG).show();
                    handledClick = false;

                }
            }
        }
    });

}

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

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

    setContentView(R.layout.activity_register);
    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);
    return_button.setOnClickListener(new View.OnClickListener() {
        @Override//from   ww w  . ja v  a  2  s  .  c o  m
        public void onClick(View v) {
            onBackPressed();
        }
    });
    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 (checkInternetConnection() == true) {
                    RequestParams params = new RequestParams();
                    params.put("email", email);
                    params.put("password", pass);
                    _piggate.RequestNewUser(params).setListenerRequest(new Piggate.PiggateCallBack() {
                        @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);
                        }

                        @Override
                        public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
                            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
                        }

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

                        @Override
                        public void onError(int statusCode, Header[] headers, String msg, JSONArray data) {
                            //Unused
                        }
                    }).exec();

                } else {
                    Toast.makeText(getApplicationContext(), "Network is not working", Toast.LENGTH_LONG).show();
                }
            }
        }
    });

}

From source file:edu.rit.csh.androidwebnews.PostSwipeableActivity.java

public void markUnread(View view) {
    int threadId = Integer.parseInt((String) view.getTag());
    findThisThread(rootThread, threadId).setUnread("manual");
    hc.markUnread(newsgroupName, threadId);
    Toast.makeText(getApplicationContext(), "Marking post as unread", Toast.LENGTH_LONG).show();
}

From source file:za.co.neilson.alarm.BaseActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    String url = null;/*  w w w.ja  v a2s. c om*/
    Intent intent = null;
    switch (item.getItemId()) {
    case R.id.menu_item_join:
        startDialog();
        break;
    case R.id.menu_item_new:

        startAlarmPreferencesActivity();
        break;
    case R.id.menu_item_rate:
        url = "market://details?id=" + getPackageName();
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(url));
        try {
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, "Couldn't launch the market", Toast.LENGTH_LONG).show();
        }
        break;
    case R.id.menu_item_website:
        url = "http://www.neilson.co.za";
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(url));
        try {
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, "Couldn't launch the website", Toast.LENGTH_LONG).show();
        }
        break;
    case R.id.menu_item_report:

        url = "https://github.com/SheldonNeilson/Android-Alarm-Clock/issues";
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(url));
        try {
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, "Couldn't launch the bug reporting website", Toast.LENGTH_LONG).show();
        }

        /*
        Intent send = new Intent(Intent.ACTION_SENDTO);
        String uriText;
                
        String emailAddress = "dontusemyemailaddress@yourdomain.com";
        String subject = R.string.app_name + " Bug Report";
        String body = "Debug:";
        body += "\n OS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL + ")";
        body += "\n OS API Level: " + android.os.Build.VERSION.SDK_INT;
        body += "\n Device: " + android.os.Build.DEVICE;
        body += "\n Model (and Product): " + android.os.Build.MODEL + " (" + android.os.Build.PRODUCT + ")";
        body += "\n Screen Width: " + getWindow().getWindowManager().getDefaultDisplay().getWidth();
        body += "\n Screen Height: " + getWindow().getWindowManager().getDefaultDisplay().getHeight();
        body += "\n Hardware Keyboard Present: " + (getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS);
                
        uriText = "mailto:" + emailAddress + "?subject=" + subject + "&body=" + body;
                
        uriText = uriText.replace(" ", "%20");
        Uri emalUri = Uri.parse(uriText);
                
        send.setData(emalUri);
        startActivity(Intent.createChooser(send, "Send mail..."));
        */
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.applechip.android.showcase.rest.HttpGetParametersActivity.java

private void showState(State state) {
    // display a notification to the user with the state
    if (state != null) {
        Toast.makeText(this, state.getFormattedName(), Toast.LENGTH_LONG).show();
    } else {//from  w  w  w . j  a v a 2 s .  c om
        Toast.makeText(this, "No state found with that abbreviation!", Toast.LENGTH_LONG).show();
    }
}

From source file:com.liferay.mobile.sample.activity.MainActivity.java

@Override
public void onFailure(Exception exception) {
    Toast.makeText(this, exception.getMessage(), Toast.LENGTH_LONG).show();
}