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.example.android.donebar.DoneButtonActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // BEGIN_INCLUDE (inflate_set_custom_view)
    // Inflate a "Done" custom action bar view to serve as the "Up" affordance.
    final LayoutInflater inflater = (LayoutInflater) getActionBar().getThemedContext()
            .getSystemService(LAYOUT_INFLATER_SERVICE);
    final View customActionBarView = inflater.inflate(R.layout.actionbar_custom_view_done, null);
    customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(new View.OnClickListener() {
        @Override//from w ww.  j  av  a 2s . c om
        public void onClick(View v) {
            // "Done"
            finish();
        }
    });

    // Show the custom action bar view and hide the normal Home icon and title.
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
            ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
    actionBar.setCustomView(customActionBarView);
    // END_INCLUDE (inflate_set_custom_view)

    AsyncHttpClient client = new AsyncHttpClient();

    client.get("http://192.168.0.101:8080/AndroidRESTful2/webresources/com.erikchenmelbourne.entities.caller",
            new JsonHttpResponseHandler() {
                @Override
                public void onSuccess(int statusCode, org.apache.http.Header[] headers,
                        org.json.JSONArray response) {
                    if (response != null) {
                        String string = response.toString();
                        try {
                            JSONArray jsonarray = new JSONArray(string);
                            Caller.jsonarraylist.clear();
                            populateArrayList(jsonarray, Caller.jsonarraylist);
                            /*for (int i = 0; i < Caller.jsonarraylist.size(); i++) {
                            Toast.makeText(getApplicationContext(), Caller.jsonarraylist.get(i).toString(), Toast.LENGTH_LONG).show();
                            }*/
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    } else {
                        Toast.makeText(getApplicationContext(),
                                "Status Code: " + statusCode + " Data has been posted.", Toast.LENGTH_LONG)
                                .show();
                    }
                }

                @Override
                public void onFailure(int statusCode, org.apache.http.Header[] headers,
                        java.lang.Throwable throwable, org.json.JSONArray errorResponse) {
                    if (statusCode == 404) {
                        Toast.makeText(getApplicationContext(), "Requested resource not found.",
                                Toast.LENGTH_LONG).show();
                    } else if (statusCode == 500) {
                        Toast.makeText(getApplicationContext(), "Something went wrong at server end.",
                                Toast.LENGTH_LONG).show();
                    } else {
                        Toast.makeText(getApplicationContext(),
                                "Unexpected Error occurred. [Most common Error: Device might not be connected to Internet or remote server is not up and running]",
                                Toast.LENGTH_LONG).show();
                    }
                }
            });

    setContentView(R.layout.activity_done_button);
}

From source file:com.oakesville.mythling.MainActivity.java

@Override
protected void onResume() {
    try {//from www  .  j  a  va 2s .c o  m
        if (getAppData() == null || getAppData().isExpired())
            refresh();
        else
            populate();
    } catch (BadSettingsException ex) {
        stopProgress();
        Toast.makeText(getApplicationContext(), getString(R.string.bad_setting_) + "\n" + ex.getMessage(),
                Toast.LENGTH_LONG).show();
    } catch (Exception ex) {
        Log.e(TAG, ex.getMessage(), ex);
        if (getAppSettings().isErrorReportingEnabled())
            new Reporter(ex).send();
        stopProgress();
        Toast.makeText(getApplicationContext(), getString(R.string.error_) + ex.toString(), Toast.LENGTH_LONG)
                .show();
    }

    super.onResume();
}

From source file:com.wahyuadityanugraha.mvpexample.app.finditems.FeedActivity.java

@Override
public void showMessage(String message) {
    Toast.makeText(this, message, Toast.LENGTH_LONG).show();
}

From source file:com.lingeringsocket.mobflare.Main.java

private void locationError() {
    Toast toast = Toast.makeText(this, R.string.no_location, Toast.LENGTH_LONG);
    toast.show();
}

From source file:com.sina.weibo.sdk.demo.openapi.WBInviteAPIActivity.java

/**
 *  //w w w.  ja va  2  s. com
 */
@Override
public void onClick(View v) {

    //  JSON ?
    JSONObject jsonObject = new JSONObject();
    try {
        jsonObject.put(InviteAPI.KEY_TEXT, "??");
        jsonObject.put(InviteAPI.KEY_URL, "http://app.sina.com.cn/appdetail.php?appID=770915");
        jsonObject.put(InviteAPI.KEY_INVITE_LOGO, "http://hubimage.com2us.com/hubweb/contents/123_499.jpg");
    } catch (JSONException e) {
        e.printStackTrace();
    }

    // ? Uid
    String uid = mEditText.getText().toString();
    //String uid = "2785593564";

    // ? Token
    Oauth2AccessToken accessToken = AccessTokenKeeper.readAccessToken(WBInviteAPIActivity.this);
    if (accessToken != null && accessToken.isSessionValid()) {
        //  OpenAPI ???
        new InviteAPI(accessToken).sendInvite(uid, jsonObject, mInviteRequestListener);
    } else {
        Toast.makeText(WBInviteAPIActivity.this, R.string.weibosdk_demo_access_token_is_empty,
                Toast.LENGTH_LONG).show();
    }
}

From source file:com.ws.wsme.openapi.WBInviteAPIActivity.java

/**
 *  // ww  w  . j  a  v a2  s .  com
 */
@Override
public void onClick(View v) {

    //  JSON ?
    JSONObject jsonObject = new JSONObject();
    try {
        jsonObject.put(InviteAPI.KEY_TEXT, "??");
        jsonObject.put(InviteAPI.KEY_URL, "http://app.sina.com.cn/appdetail.php?appID=770915");
        jsonObject.put(InviteAPI.KEY_INVITE_LOGO, "http://hubimage.com2us.com/hubweb/contents/123_499.jpg");
    } catch (JSONException e) {
        e.printStackTrace();
    }

    // ? Uid
    String uid = mEditText.getText().toString();
    //String uid = "2785593564";

    // ? Token
    Oauth2AccessToken accessToken = com.ws.wsme.common.AccessTokenKeeper
            .readAccessToken(WBInviteAPIActivity.this);
    if (accessToken != null && accessToken.isSessionValid()) {
        //  OpenAPI ???
        new InviteAPI(accessToken).sendInvite(uid, jsonObject, mInviteRequestListener);
    } else {
        Toast.makeText(WBInviteAPIActivity.this, com.ws.wsme.R.string.weibosdk_demo_access_token_is_empty,
                Toast.LENGTH_LONG).show();
    }
}

From source file:com.radicaldynamic.groupinform.activities.AccountDeviceList.java

/**
 * Stores the path of selected form and finishes.
 */// w  ww  . ja  v a2s . co m
@Override
protected void onListItemClick(ListView listView, View view, int position, long id) {
    AccountDevice device = (AccountDevice) getListAdapter().getItem(position);

    // Only account owners should proceed to the next screen
    if (Collect.getInstance().getInformOnlineState().isAccountOwner()
            || Collect.getInstance().getInformOnlineState().getDeviceRole().equals(AccountDevice.ROLE_ADMIN)) {
        Intent i = new Intent(this, AccountDeviceActivity.class);
        i.putExtra(AccountDeviceActivity.KEY_DEVICE_ID, device.getId());
        startActivity(i);
    } else {
        Toast.makeText(getApplicationContext(), getString(R.string.tf_action_reserved_for_admin),
                Toast.LENGTH_LONG).show();
    }
}

From source file:com.scooter1556.sms.androidtv.fragment.MediaFolderGridFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set media folder
    folder = (MediaFolder) getActivity().getIntent().getSerializableExtra("Folder");

    if (folder == null) {
        Toast.makeText(getActivity(), getString(R.string.error_loading_media), Toast.LENGTH_LONG).show();
        getActivity().finishAfterTransition();
    }//from   w  w  w .j  av a2  s .  co  m

    if (savedInstanceState == null) {
        setTitle(folder.getName());
        prepareEntranceTransition();
    }

    // Initialise interface
    prepareBackgroundManager();
    VerticalGridPresenter gridPresenter = new VerticalGridPresenter();
    gridPresenter.setNumberOfColumns(NUM_COLUMNS);
    setGridPresenter(gridPresenter);

    setOnSearchClickedListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // ToDo: Implement search feature
            Toast.makeText(getActivity(), getString(R.string.error_search_not_implemented), Toast.LENGTH_SHORT)
                    .show();
        }
    });

    setOnItemViewClickedListener(new ItemViewClickedListener());
    setOnItemViewSelectedListener(new ItemViewSelectedListener());

    // Set search icon color.
    setSearchAffordanceColor(ContextCompat.getColor(getActivity(), R.color.search_opaque));

    getMediaElements();
}

From source file:com.burntout.burntout.AddCarActivity.java

public void addListenerOnSubmit() {

    submitBtn.setOnClickListener(new OnClickListener() {

        @Override/* w w  w. j  av  a2  s  . c o m*/
        public void onClick(View v) {

            int vTypeInt = vehicleTypeHSV.getActiveFeature();
            vType = Integer.toString(vTypeInt);
            Log.d("vtype", vType);
            makeModel = makeModelEntry.getText().toString().trim();
            vState = statePicker.getSelectedItem().toString();
            vPlateNumber = plateNumberEntry.getText().toString().trim();

            if (makeModel.length() < 1) {
                Toast.makeText(AddCarActivity.this, "Car Model can't be empty!", Toast.LENGTH_LONG).show();
            } else if (vPlateNumber.length() < 1) {
                Toast.makeText(AddCarActivity.this, "License Plate can't be empty!", Toast.LENGTH_LONG).show();
            } else {
                loginBurnt(vType, makeModel, vState, vPlateNumber);
            }

        }

    });
}

From source file:gcm.play.android.samples.com.gcmquickstart.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getSupportActionBar().hide();/*from  w  ww  . j a va 2 s.  c  o  m*/

    etUsername = (EditText) findViewById(R.id.etUsername);
    etPassword = (EditText) findViewById(R.id.etPassword);
    btnIniciarSesion = (Button) findViewById(R.id.btnIniciarSesion);
    cbRecordar = (CheckBox) findViewById(R.id.cbRecordar);

    progressDialog = new ProgressDialog(this, R.style.MyTheme);

    //Se establece como usuario la cuenta registrada por el usuario para que haga su inicio de sesin
    userName = UserData.getUserAccount(this);
    Log.d("USER_ACCOUNT_LOCAL", userName);
    etUsername.setText(userName);

    //Establece como no editable el edit text de Usuario
    etUsername.setKeyListener(null);

    //progressDialog = new ProgressDialog(this, R.style.MyTheme);
    progressDialog.setTitle("Registration ID");
    progressDialog.setMessage("Espere un momento...");
    progressDialog.setCancelable(false);
    progressDialog.setCanceledOnTouchOutside(false);
    progressDialog.show();
    mRegistrationBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            progressDialog.dismiss();
            SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
            boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false);
            if (sentToken) {
                Toast.makeText(getApplicationContext(), getString(R.string.gcm_ready), Toast.LENGTH_LONG)
                        .show();

            } else {
                Toast.makeText(getApplicationContext(), getString(R.string.gcm_not_ready), Toast.LENGTH_LONG)
                        .show();

            }
        }
    };

    if (checkPlayServices()) {
        // Start IntentService to register this application with GCM.
        Intent intent = new Intent(this, RegistrationIntentService.class);
        startService(intent);
    }

    //Evento click para iniciar sesin
    btnIniciarSesion.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startSession();
        }
    });

}