List of usage examples for android.widget Toast LENGTH_LONG
int LENGTH_LONG
To view the source code for android.widget Toast LENGTH_LONG.
Click Source Link
From source file:cn.com.jinyinmao.app.openapi.WBInviteAPIActivity.java
/** * // ww w .ja va 2 s. c o m */ @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(this, Constants.APP_KEY, 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.hybris.mobile.activity.AbstractProductDetailActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { boolean handled = super.onOptionsItemSelected(item); if (!handled) { // Put custom menu items handlers here switch (item.getItemId()) { // NFC writing is for debug use only case R.id.write_tag: if (NFCUtil.canNFC(this)) { Intent writeIntent = new Intent(this, NFCWriteActivity.class); NdefMessage msg = getNDEF(mProduct.getCode()); writeIntent.putExtra(NFCWriteActivity.NDEF_MESSAGE, msg); startActivity(writeIntent); } else { Toast.makeText(this, R.string.error_nfc_not_supported, Toast.LENGTH_LONG).show(); }/* www . ja v a 2s . c o m*/ return true; case R.id.share: try { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, mProduct.getName() + " - " + getString(R.string.nfc_url, URLEncoder.encode(mProduct.getCode(), "UTF-8"))); sendIntent.setType("text/plain"); startActivity(Intent.createChooser(sendIntent, getString(R.string.share_dialog_title))); } catch (UnsupportedEncodingException e) { LoggingUtils.e(LOG_TAG, "Error trying to encode product code to UTF-8. " + e.getLocalizedMessage(), Hybris.getAppContext()); } return true; default: return false; } } return handled; }
From source file:net.networksaremadeofstring.cyllell.ViewCookbooks_Fragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { settings = this.getActivity().getSharedPreferences("Cyllell", 0); try {//w w w.jav a2 s . c o m Cut = new Cuts(getActivity()); } catch (Exception e) { e.printStackTrace(); } dialog = new ProgressDialog(getActivity()); dialog.setTitle("Contacting Chef"); dialog.setMessage("Please wait: Prepping Authentication protocols"); dialog.setIndeterminate(true); if (listOfCookbooks.size() < 1) { dialog.show(); } updateListNotify = new Handler() { public void handleMessage(Message msg) { int tag = msg.getData().getInt("tag", 999999); if (msg.what == 0) { if (tag != 999999) { listOfCookbooks.get(tag).SetSpinnerVisible(); } } else if (msg.what == 1) { //Get rid of the lock CutInProgress = false; //the notifyDataSetChanged() will handle the rest } else if (msg.what == 99) { if (tag != 999999) { Toast.makeText(ViewCookbooks_Fragment.this.getActivity(), "An error occured during that operation.", Toast.LENGTH_LONG).show(); listOfCookbooks.get(tag).SetErrorState(); } } CookbookAdapter.notifyDataSetChanged(); } }; handler = new Handler() { public void handleMessage(Message msg) { //Once we've checked the data is good to use start processing it if (msg.what == 0) { OnClickListener listener = new OnClickListener() { public void onClick(View v) { GetMoreDetails((Integer) v.getTag()); } }; OnLongClickListener listenerLong = new OnLongClickListener() { public boolean onLongClick(View v) { //selectForCAB((Integer)v.getTag()); Toast.makeText(getActivity(), "This version doesn't support Cookbook editing yet", Toast.LENGTH_SHORT).show(); return true; } }; CookbookAdapter = new CookbookListAdaptor(getActivity(), listOfCookbooks, listener, listenerLong); try { list = (ListView) getView().findViewById(R.id.cookbooksListView); } catch (Exception e) { e.printStackTrace(); } if (list != null) { if (CookbookAdapter != null) { list.setAdapter(CookbookAdapter); } else { //Log.e("CookbookAdapter","CookbookAdapter is null"); } } else { //Log.e("List","List is null"); } dialog.dismiss(); } else if (msg.what == 200) { dialog.setMessage("Sending request to Chef..."); } else if (msg.what == 201) { dialog.setMessage("Parsing JSON....."); } else if (msg.what == 202) { dialog.setMessage("Populating UI!"); } else { //Close the Progress dialog dialog.dismiss(); //Alert the user that something went terribly wrong AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setTitle("API Error"); alertDialog.setMessage("There was an error communicating with the API:\n" + msg.getData().getString("exception")); alertDialog.setButton2("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //getActivity().finish(); } }); alertDialog.setIcon(R.drawable.icon); alertDialog.show(); } } }; Thread dataPreload = new Thread() { public void run() { if (listOfCookbooks.size() > 0) { handler.sendEmptyMessage(0); } else { try { handler.sendEmptyMessage(200); Cookbooks = Cut.GetCookbooks(); handler.sendEmptyMessage(201); JSONArray Keys = Cookbooks.names(); String URI = ""; String Version = "0.0.0"; JSONObject cookbook; for (int i = 0; i < Cookbooks.length(); i++) { cookbook = new JSONObject(Cookbooks.getString(Keys.get(i).toString())); //URI = Cookbooks.getString(Keys.get(i).toString()).replaceFirst("^(https://|http://).*/cookbooks/", ""); //Version = Cookbooks.getString(Keys.get(i).toString()) //Log.i("Cookbook Name", Keys.get(i).toString()); URI = cookbook.getString("url").replaceFirst("^(https://|http://).*/cookbooks/", ""); //Log.i("Cookbook URL", URI); JSONArray versions = cookbook.getJSONArray("versions"); Version = versions.getJSONObject(versions.length() - 1).getString("version"); //Log.i("Cookbook version", Version); listOfCookbooks.add(new Cookbook(Keys.get(i).toString(), URI, Version)); } handler.sendEmptyMessage(202); handler.sendEmptyMessage(0); } catch (Exception e) { BugSenseHandler.log("ViewCookbooksFragment", e); e.printStackTrace(); Message msg = new Message(); Bundle data = new Bundle(); data.putString("exception", e.getMessage()); msg.setData(data); msg.what = 1; handler.sendMessage(msg); } } return; } }; dataPreload.start(); return inflater.inflate(R.layout.cookbooks_landing, container, false); }
From source file:net.networksaremadeofstring.rhybudd.DeviceList.java
/** Called when the activity is first created. */ @SuppressWarnings({ "unchecked", "deprecation" }) @Override//from ww w. j av a 2s.c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); settings = PreferenceManager.getDefaultSharedPreferences(this); setContentView(R.layout.devicelist); BugSenseHandler.initAndStartSession(DeviceList.this, "44a76a8c"); actionbar = getActionBar(); actionbar.setDisplayHomeAsUpEnabled(true); actionbar.setHomeButtonEnabled(true); actionbar.setTitle("Infrastructure"); list = (ListView) findViewById(R.id.ZenossDeviceList); BugSenseHandler.initAndStartSession(DeviceList.this, "44a76a8c"); handler = new Handler() { public void handleMessage(Message msg) { if (msg.what == 0) { Toast.makeText(DeviceList.this, "An error was encountered;\r\n" + msg.getData().getString("exception"), Toast.LENGTH_LONG).show(); } else if (msg.what == 1) { dialog.setMessage("Refresh Complete!"); this.sendEmptyMessageDelayed(2, 1000); } else if (msg.what == 2) { dialog.dismiss(); adapter = new ZenossDeviceAdaptor(DeviceList.this, listOfZenossDevices); list.setAdapter(adapter); ((TextView) findViewById(R.id.ServerCountLabel)) .setText("Monitoring " + DeviceCount + " servers"); } } }; try { listOfZenossDevices = (List<ZenossDevice>) getLastNonConfigurationInstance(); } catch (Exception e) { listOfZenossDevices = null; //BugSenseHandler.log("DeviceList", e); } if (listOfZenossDevices == null || listOfZenossDevices.size() < 1) { listOfZenossDevices = new ArrayList<ZenossDevice>(); DBGetThread(); } else { adapter = new ZenossDeviceAdaptor(DeviceList.this, listOfZenossDevices); list.setAdapter(adapter); } }
From source file:eu.thecoder4.gpl.pleftdroid.EditEventActivity.java
/** Called when the activity is first created. */ @Override/*w w w. j a v a2 s.co m*/ public void onCreate(Bundle savedInstanceState) { if (AppPreferences.INSTANCE.getUsePleftTheme()) { setTheme(R.style.Theme_Pleft); } super.onCreate(savedInstanceState); // Initialiazations mTHISEVENT = this; mDates = new ArrayList<PDate>(); mEmails = new ArrayList<String>(); // The View setContentView(R.layout.edit_event); // Add Invitee Button ((Button) findViewById(R.id.addinvitee)).setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent iai = new Intent(mTHISEVENT, SelectContactsActivity.class); startActivityForResult(iai, ACT_INVITEE); } }); // Add Date Button ((Button) findViewById(R.id.adddate)).setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent iad = new Intent(mTHISEVENT, PickDateDialogActivity.class); // This would not work: you need a Parcelable //iad.putExtra(PickDateDialogActivity.DTLIST, mDates); iad.putParcelableArrayListExtra(PickDateDialogActivity.DTLIST, mDates); startActivityForResult(iad, ACT_ADDDATE); } }); // Send Invitations Button ((Button) findViewById(R.id.sendinvite)).setOnClickListener(new OnClickListener() { private int SC; @SuppressWarnings("static-access") public void onClick(View v) { String desc = ((EditText) findViewById(R.id.edescription)).getText().toString(); String invitees = ((EditText) findViewById(R.id.einvitees)).getText().toString(); String dates = getPleftDates();//"2011-06-23T21:00:00\n2011-06-24T21:00:00\n2011-06-25T21:00:00"; boolean proposemore = ((CheckBox) findViewById(R.id.mayproposedate)).isChecked(); if (desc == null || desc.length() == 0 || invitees == null || invitees.length() == 0 || dates == null || dates.length() == 0) { Toast.makeText(EditEventActivity.this, R.string.event_completeform, Toast.LENGTH_LONG).show(); } else { // Get Preferences //Toast.makeText(EditEventActivity.this, "invitees: "+invitees+"\nDesc="+desc+"\npserver="+pserver, Toast.LENGTH_LONG).show(); SC = PleftBroker.INSTANCE.createAppointment(desc, invitees, dates, AppPreferences.INSTANCE.getPleftServer().trim(), //pserver, AppPreferences.INSTANCE.getName().trim(), //uname, AppPreferences.INSTANCE.getEmail().trim(), //uemail, proposemore); if (SC == HttpStatus.SC_OK) { PleftDroidDbAdapter mDbAdapter = new PleftDroidDbAdapter(EditEventActivity.this); mDbAdapter.open(); mDbAdapter.createAppointmentAsInvitor(0, desc, AppPreferences.INSTANCE.getPleftServer().trim(), AppPreferences.INSTANCE.getEmail().trim()); mDbAdapter.close(); } Bundle bundle = new Bundle(); bundle.putInt(PleftDroidActivity.SC_CREATE, SC); Intent i = new Intent(); i.putExtras(bundle); setResult(RESULT_OK, i); // Close activity finish(); } } }); }
From source file:com.google.maps.android.utils.demo.HeatmapsDemoActivity.java
@Override protected void startDemo() { getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-25, 143), 4)); // Set up the spinner/dropdown list Spinner spinner = (Spinner) findViewById(R.id.spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.heatmaps_datasets_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter);/* ww w.ja va 2 s . co m*/ spinner.setOnItemSelectedListener(new SpinnerActivity()); try { mLists.put(getString(R.string.police_stations), new DataSet(readItems(R.raw.police), getString(R.string.police_stations_url))); mLists.put(getString(R.string.medicare), new DataSet(readItems(R.raw.medicare), getString(R.string.medicare_url))); } catch (JSONException e) { Toast.makeText(this, "Problem reading list of markers.", Toast.LENGTH_LONG).show(); } // Make the handler deal with the map // Input: list of WeightedLatLngs, minimum and maximum zoom levels to calculate custom // intensity from, and the map to draw the heatmap on // radius, gradient and opacity not specified, so default are used }
From source file:br.ufsc.das.gtscted.shibbauth.SPSelectionActivity.java
/** Called when the activity is first created. */ @Override/*from ww w.j a v a2 s. c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sp_selection); nextButton = (Button) findViewById(R.id.nextButton); exitButton = (Button) findViewById(R.id.exitButton); spEditText = (EditText) findViewById(R.id.spUrlEditText); //SP para testes spEditText.setText("https://sp.ufrgs.br/chimarrao/"); nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String serviceUrl = spEditText.getText().toString(); try { Connection connection = new Connection(); String[] getResponseAndEndpoint = connection.httpGetWithEndpoint(serviceUrl); String wayfLocation = getResponseAndEndpoint[0]; String responseBody = getResponseAndEndpoint[1]; Bundle bundle = new Bundle(); bundle.putString("html_source", responseBody); bundle.putString("wayf_location", wayfLocation); bundle.putSerializable("cookie", connection.getSerializableCookie(0)); Intent newIntent = new Intent(SPSelectionActivity.this, ShibAuthenticationActivity.class); newIntent.putExtras(bundle); startActivity(newIntent); } catch (KeyManagementException e) { String message = "KeyManagementException"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } catch (NoSuchAlgorithmException e) { String message = "NoSuchAlgorithmException"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } catch (KeyStoreException e) { String message = "KeyStoreException"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } catch (UnrecoverableKeyException e) { String message = "UnrecoverableKeyException"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } catch (ClientProtocolException e) { String message = "ClientProtocolException"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } catch (IOException e) { String message = "IOException"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } catch (Exception e) { String message = "Exception"; Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG); toast.show(); } } }); exitButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); }
From source file:com.github.notizklotz.derbunddownloader.issuesgrid.DownloadedIssuesActivity.java
@Override protected void onStart() { super.onStart(); String username = Settings.getUsername(getApplicationContext()); String password = Settings.getPassword(getApplicationContext()); if (!(StringUtils.hasText(username) && StringUtils.hasText(password))) { SettingsActivity_.intent(this).start(); Toast.makeText(this, getString(R.string.please_login), Toast.LENGTH_LONG).show(); }/* w w w. java 2s .c o m*/ }
From source file:com.flat20.fingerplay.FingerPlayActivity.java
@Override public void onCreate(Bundle savedInstanceState) { // Init needs to be done first! mSettingsModel = SettingsModel.getInstance(); mSettingsModel.init(this); mMidiControllerManager = MidiControllerManager.getInstance(); super.onCreate(savedInstanceState); Runtime r = Runtime.getRuntime(); r.gc();/*w w w . j a v a 2s. c o m*/ Toast info = Toast.makeText(this, "Go to http://goddchen.github.io/Fingerplay-Midi/ for help.", Toast.LENGTH_LONG); info.show(); // Sensor code sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); sensors = new ArrayList<Sensor>(sensorManager.getSensorList(Sensor.TYPE_ALL)); startSensors(); // Simple splash animation Splash navSplash = new Splash(mNavigationOverlay, 64, 30, mWidth, mNavigationOverlay.x); mNavigationOverlay.x = mWidth; AnimationManager.getInstance().add(navSplash); Splash mwcSplash = new Splash(mMidiWidgetsContainer, 64, 40, -mWidth, mMidiWidgetsContainer.x); mMidiWidgetsContainer.x = -mWidth; AnimationManager.getInstance().add(mwcSplash); if (BuildConfig.DEBUG) { if (TextUtils.isEmpty(PreferenceManager.getDefaultSharedPreferences(this) .getString("settings_server_address", null))) { Toast.makeText(this, R.string.toast_server_not_setup, Toast.LENGTH_SHORT).show(); startActivity(new Intent(getApplicationContext(), SettingsView.class)); } } else { boolean result = bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"), mBillingServiceConnection, Context.BIND_AUTO_CREATE); if (!result) { unableToVerifyLicense(getString(R.string.billing_error_init), false); } } }