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:org.lol.reddit.common.General.java
public static void quickToast(final Context context, final String text) { UI_THREAD_HANDLER.post(new Runnable() { public void run() { Toast.makeText(context, text, Toast.LENGTH_LONG).show(); }//from w ww .jav a 2 s . c o m }); }
From source file:com.galois.qrstream.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setupUI();//from ww w .ja va2 s . c om hideUI(); fragmentManager = getFragmentManager(); transmitFragment = new TransmitFragment(); receiveFragment = new ReceiveFragment(); settingsFragment = new SettingsFragment(); // Load application's default settings before user opens settings // screen because we want Rx and Tx to run with defaults. PreferenceManager.setDefaultValues(this, com.galois.qrstream.lib.R.xml.settings, false); if (savedInstanceState == null) { Intent startingIntent = getIntent(); Log.d(Constants.APP_TAG, "startingIntent " + startingIntent.getAction()); if (startingIntent.getAction().equals(Intent.ACTION_SEND)) { try { Job job = buildJobFromIntent(startingIntent); Bundle bundle = new Bundle(); bundle.putSerializable("job", job); transmitFragment.setArguments(bundle); showFragment(transmitFragment); } catch (IllegalArgumentException e) { Toast.makeText(this, "Unsupported media type.", Toast.LENGTH_LONG).show(); finish(); } } else { showFragment(receiveFragment); } } }
From source file:com.kinvey.sample.signin.GoogleLoginActivity.java
private void loginGoogleKinveyUser() { mKinveyClient.user().loginGoogle(getAuthToken(), new KinveyUserCallback() { public void onFailure(Throwable e) { Log.e(TAG, "Failed Kinvey login", e); // TextView tv = (TextView) findViewById(R.id.output); String b = new String(e.getMessage()); Log.e(AuthorizedActivity.TAG, "Error: " + b); // tv.setText("DOH! Great Scott!\nKinvey: " + b); };/*from w w w. j a v a2 s . co m*/ @Override public void onSuccess(User r) { CharSequence text = "Logged in."; Toast.makeText(getApplicationContext(), text, Toast.LENGTH_LONG).show(); GoogleLoginActivity.this.startActivity(new Intent(GoogleLoginActivity.this, MainActivity.class)); GoogleLoginActivity.this.finish(); } }); }
From source file:com.piggate.samples.PiggateLoginService.Activity_Main.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); _piggate = new Piggate(this, null); //Initialize a Piggate object //Handles if the user is already login Boolean logout = false;/* w w w . j a v a 2 s.c o m*/ if (getIntent().getExtras() != null) logout = getIntent().getExtras().getBoolean("ACTIVITY_MAIN_CREATED_BY_BUTTON_LOGOUT", false); setContentView(R.layout.activity_main); final Button login = (Button) findViewById(R.id.buttonloginmain); final Button register = (Button) findViewById(R.id.buttonregistermain); //onClick listener of the login button: go to Activity_SingIn login.setOnClickListener(new View.OnClickListener() { @Override synchronized public void onClick(View v) { if (!handledClick) { handledClick = true; Intent slideactivity = new Intent(Activity_Main.this, Activity_SingIn.class); Bundle bndlanimation = ActivityOptions .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle(); startActivity(slideactivity, bndlanimation); } } }); //onClick listener of the register button: go to Activity_SingUp register.setOnClickListener(new View.OnClickListener() { @Override synchronized public void onClick(View v) { if (!handledClick) { handledClick = true; Intent slideactivity = new Intent(Activity_Main.this, Activity_SingUp.class); Bundle bndlanimation = ActivityOptions .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle(); startActivity(slideactivity, bndlanimation); } } }); //If you close the application without logout, the session will be active //Call a listener of the RequestUser method for Piggate object if (!logout && checkInternetConnection()) _piggate.RequestUser().setListenerRequest(new Piggate.PiggateCallBack() { //Method onComplete for JSONObject //If the request is completed correctly the user is redirected to Activity_Logged @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_Main.this, Activity_Logged.class); Bundle bndlanimation = ActivityOptions .makeCustomAnimation(getApplicationContext(), R.anim.flip1, R.anim.flip2).toBundle(); startActivity(slideactivity, bndlanimation); } //Method onError for JSONObject //When we have an error, reload the Piggate object @Override public void onError(int statusCode, Header[] headers, String msg, JSONObject data) { _piggate.reload(); } //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(); }
From source file:es.wolfi.passman.API.Core.java
/** * Check if the user has logged in, also sets up the API * @param c The context where this should be run * @param toast Whether we want or not a toast! Yum! * @param cb The callback/*from w w w.j a v a2s. c o m*/ */ public static void checkLogin(final Context c, final boolean toast, final FutureCallback<Boolean> cb) { SingleTon ton = SingleTon.getTon(); if (ton.getString(SettingValues.HOST.toString()) == null) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(c); String url = settings.getString(SettingValues.HOST.toString(), null); // If the url is null app has not yet been configured! if (url == null) { cb.onCompleted(null, false); return; } // Load the server settings ton.addString(SettingValues.HOST.toString(), url); ton.addString(SettingValues.USER.toString(), settings.getString(SettingValues.USER.toString(), "")); ton.addString(SettingValues.PASSWORD.toString(), settings.getString(SettingValues.PASSWORD.toString(), "")); } String host = ton.getString(SettingValues.HOST.toString()); String user = ton.getString(SettingValues.USER.toString()); String pass = ton.getString(SettingValues.PASSWORD.toString()); Toast.makeText(c, host, Toast.LENGTH_LONG).show(); Log.d(LOG_TAG, "Host: " + host); Log.d(LOG_TAG, "User: " + user); Log.d(LOG_TAG, "Pass: " + pass); Vault.setUpAPI(host, user, pass); Vault.getVaults(c, new FutureCallback<HashMap<String, Vault>>() { @Override public void onCompleted(Exception e, HashMap<String, Vault> result) { boolean ret = true; if (e != null) { if (e.getMessage().equals("401")) { if (toast) Toast.makeText(c, c.getString(R.string.wrongNCSettings), Toast.LENGTH_LONG).show(); ret = false; } else if (e.getMessage().contains("Unable to resolve host") || e.getMessage().contains("Invalid URI")) { if (toast) Toast.makeText(c, c.getString(R.string.wrongNCUrl), Toast.LENGTH_LONG).show(); ret = false; } else { Log.e(LOG_TAG, "Error: " + e.getMessage(), e); if (toast) Toast.makeText(c, c.getString(R.string.net_error) + ": " + e.getMessage(), Toast.LENGTH_LONG).show(); ret = false; } } cb.onCompleted(e, ret); } }); }
From source file:com.gigathinking.simpleapplock.Upgrade.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 777) { if (resultCode == RESULT_OK) { int responseCode = data.getIntExtra("RESPONSE_CODE", 0); String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA"); String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE"); if (responseCode == 0) { try { JSONObject jo = new JSONObject(purchaseData); String sku = jo.getString("productId"); if (sku.equals("no_ads")) { mPrefs.edit().putBoolean("no_ads_purchased", true).commit(); }//from ww w . j a va 2s.co m if (sku.equals("adv_prot")) { mPrefs.edit().putBoolean("adv_prot_purchased", true).commit(); } Toast.makeText(this, getString(R.string.upgrage_on_next_restart), Toast.LENGTH_LONG).show(); } catch (JSONException e) { e.printStackTrace(); } } } } }
From source file:com.nextgis.maplibui.util.NGWCreateNewResourceTask.java
@Override protected void onPostExecute(String result) { super.onPostExecute(result); String message;/*from w w w . j ava 2 s. com*/ if (!MapUtil.isParsable(result)) { try { JSONObject obj = new JSONObject(result); Long id = obj.getLong(Constants.JSON_ID_KEY); if (mLayer != null) mLayer.toNGW(id, mConnection.getName(), Constants.SYNC_ALL, mVer); result = "-999"; } catch (JSONException e) { result = "500"; e.printStackTrace(); } } switch (result) { case "-999": message = mContext .getString(mLayer == null ? R.string.message_group_created : R.string.message_layer_created); break; default: message = NetworkUtil.getError(mContext, result); break; } Toast.makeText(mContext, message, Toast.LENGTH_LONG).show(); }
From source file:com.gmail.emerssso.srbase.EditSRActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.edit_sr_activity); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(R.string.edit_sr); }//w w w . j a v a 2s . c o m mSRNumber = (EditText) findViewById(R.id.SRNumber); mCustomer = (EditText) findViewById(R.id.customerName); mModelNumber = (EditText) findViewById(R.id.modelNumber); mSerialNumber = (EditText) findViewById(R.id.serialNumber); mDescription = (EditText) findViewById(R.id.description); mBusinessName = (EditText) findViewById(R.id.businessName); /* The Daily Button opens a dialog to add a new daily associated with this SR. */ Button mDaily = (Button) findViewById(R.id.add_daily); /* The Part Button opens a new dialog to add a new part associated with this SR.. */ Button mPart = (Button) findViewById(R.id.add_part); /* The Confirm Button saves the SR to the database. */ Button mEnter = (Button) findViewById(R.id.confirm); Bundle extras = getIntent().getExtras(); savedUri = (savedInstanceState == null) ? null : (Uri) savedInstanceState.getParcelable(SRContentProvider.SR_CONTENT_ITEM_TYPE); if (extras != null) { savedUri = extras.getParcelable(SRContentProvider.SR_CONTENT_ITEM_TYPE); fillData(savedUri); } if (savedUri != null) { myId = savedUri.getLastPathSegment(); } mEnter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mSRNumber.getText().toString().length() == 0) { Toast.makeText(EditSRActivity.this, "SR Number missing", Toast.LENGTH_LONG).show(); } else { saveState(); setResult(RESULT_OK); finish(); } } }); mPart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveState(); addPart(); } }); mDaily.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveState(); addDaily(); } }); }
From source file:com.ibm.sample.travelbuddy.MainActivity.java
/** * This method searches the Watson QA service by using the question text *//*from w ww . ja va2 s.c om*/ private void doSearch() { String sTxt = searchTxt.getText().toString(); if (sTxt.trim().equals("")) { Toast.makeText(getApplicationContext(), "Please enter your question", Toast.LENGTH_SHORT).show(); return; } RequestParams param = new RequestParams(); param.add("questionText", sTxt); HttpUtil.get(param, new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, JSONObject response) { Log.i("doSearch", response.toString()); try { String respCode = response.getString("respCode"); if (respCode.equals(HttpUtil.RESP_SUCCESS)) { JSONArray bodyArray = response.getJSONArray("body"); itemList.clear(); for (int i = 0; i < bodyArray.length(); i++) { JSONObject obj = bodyArray.getJSONObject(i); itemList.add("(" + obj.getString("confidence") + ") " + obj.getString("text")); } adapter.notifyDataSetChanged(); } else { Toast.makeText(getApplicationContext(), response.getString("respText"), Toast.LENGTH_LONG) .show(); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); }
From source file:fr.julienvermet.bugdroid.ui.BugCommentsFragment.java
private void postComment() { try {/* w w w .j a v a2 s. c om*/ String message = mCommentMessage.getText().toString(); if (message.isEmpty()) { Toast.makeText(getActivity(), R.string.comment_empty, Toast.LENGTH_LONG).show(); return; } mCommentSendProgress.setVisibility(View.VISIBLE); mCommentSend.setVisibility(View.GONE); JSONObject jsonData = new JSONObject(); jsonData.put("text", message); Intent intent = CommentIntentService.getIntent(getActivity(), mInstance, mBug.bugId, jsonData); Messenger messenger = new Messenger(onCommentHandler); intent.putExtra(CommentIntentService.MESSENGER, messenger); getActivity().startService(intent); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }