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:at.metalab.donarsson.screeninvader.InvadeScreen.java

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

    ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(
            Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if (networkInfo.isConnected()) {
        //TODO: Check if we know a ScreenInvader on this network
        Intent intent = getIntent();/*from  ww w.  j  a va2s .com*/
        String type = intent.getType();
        if (type.startsWith("text/")) {
            String text = intent.getStringExtra(Intent.EXTRA_TEXT);
            Pattern pattern = Patterns.WEB_URL;
            Matcher matcher = pattern.matcher(text);
            while (matcher.find()) {
                String url = matcher.group();
                new PostUrlTask().execute(url);
            }
        } //TODO: Add support for other types (file upload)
    } else {
        //TODO: Display a prompt to connect to a WiFi
        Toast.makeText(getApplicationContext(), getString(R.string.no_wifi_toast), Toast.LENGTH_LONG).show();
    }
    finish();
}

From source file:com.wso2.mobile.mdm.services.WSO2DeviceAdminReceiver.java

/** Called when this application is approved to be a device administrator. */
@Override/*w  w w.ja v  a2  s. c om*/
public void onEnabled(Context context, Intent intent) {
    super.onEnabled(context, intent);
    String policy;
    JSONArray jArray = null;
    operation = new Operation(context);
    SharedPreferences mainPref = context.getSharedPreferences("com.mdm", Context.MODE_PRIVATE);

    try {
        policy = mainPref.getString("policy", "");
        if (policy != null && !policy.equals("")) {
            operation.executePolicy();
        }
    } catch (Exception ex) {

    }
    Toast.makeText(context, R.string.device_admin_enabled, Toast.LENGTH_LONG).show();
    Log.d(TAG, "onEnabled");

}

From source file:com.wms.ezyoukuuploader.sdk.task.YoukuVideoUploadTask.java

@Override
protected String doInBackground(String... params) { // params[0] is file name, params[1] is video title, params[2] is description
    YoukuUploader youkuUploader = activity.getYoukuUploader();

    HashMap<String, String> parameters = new HashMap<>();
    String accessToken = SharedPreferenceUtil.getPreferenceItemByName(activity,
            SharedPreferenceUtil.YoukuAccessToken);
    parameters.put(YoukuConstants.PARAM_ACCESS_TOKEN, accessToken);

    HashMap<String, String> uploadInfo = new HashMap<>();
    uploadInfo.put("file_name", params[0]);
    uploadInfo.put("title", params[1]);
    uploadInfo.put("description", params[2]);
    uploadInfo.put("tags", "EZYoukuUploader");

    youkuUploader.upload(parameters, uploadInfo, new IUploadResponseHandler() {

        @Override// w  w  w  .java  2 s  .  c o m
        public void onStart() {
            activity.toggleUploadingFlag(true);
            activity.toggleWidgetsEnabled(false);
            activity.resetProgress();
            Toast.makeText(activity, activity.getString(R.string.startUploadingVideo), Toast.LENGTH_LONG)
                    .show();
        }

        @Override
        public void onSuccess(JSONObject response) {
            activity.getTextViewProgress().setText("100%");
            try {
                String videoId = response.getString("video_id");
                activity.getTextViewVideoUrl().setText("http://v.youku.com/v_show/id_" + videoId);
            } catch (JSONException e) {
                // URL will not be updated
            }

            activity.toggleWidgetsEnabled(true);
            activity.preventUploadingSameVideo();
            Toast.makeText(activity, activity.getString(R.string.videoUploadCompleted), Toast.LENGTH_LONG)
                    .show();
        }

        @Override
        public void onProgressUpdate(int counter) {
            activity.getProgressBarUploadVideo().setProgress(counter);
            if (counter < 10) {
                activity.getTextViewProgress().setText(" 0" + counter + "%");
            } else {
                activity.getTextViewProgress().setText(" " + counter + "%");
            }
        }

        @Override
        public void onFailure(JSONObject errorResponse) {
            activity.toggleWidgetsEnabled(true);
            DialogUtil.showExceptionAlertDialog(activity, activity.getString(R.string.videoUploadFailedTitle),
                    activity.getString(R.string.videoUploadFailed));
        }

        @Override
        public void onFinished() {
            activity.toggleUploadingFlag(false);
        }
    });

    return null;
}

From source file:eltharis.wsn.showIDActivity.java

/**
 * Called when the activity is first created.
 *//*from  w w  w  . j a v  a  2s . co m*/
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.showid_layout);
    int id = getIntent().getIntExtra("id", -1); //pobieramy z Extra parametr id
    try {
        String httpresponse = executeGET(id);
        showId(httpresponse);
    } catch (Exception e) {
        Toast toast = Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG);
        toast.show();
    }
    // ToDo add your GUI initialization code here        
}

From source file:com.mobshep.insufficienttls.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    referenceXML();/*from  w  w w  .j  ava 2 s  .  c  o  m*/

    logPrefSession();
    logProviderSession();

    if (checkSession()) {
        // Intent intent = new Intent(MainActivity.this, LoggedIn.class);
        // startActivity(intent);
    }

    //TODO
    //Remove this and replace with AsyncTask
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
    //end remove

    SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    String address = SP.getString("server_preference", "NA");

    Toast addressTest = Toast.makeText(MainActivity.this, "Server Address : " + address, Toast.LENGTH_LONG);
    addressTest.show();

}

From source file:com.temboo.example.YouTubeResultView.java

public YouTubeResultView(Context context, String title, String url, String thumbnailURL) {
    super(context);
    super.setOrientation(HORIZONTAL);

    // Create the link text view, and make the link clickable
    linkView = new TextView(getContext());
    linkView.setMovementMethod(LinkMovementMethod.getInstance());

    // Set the link text
    linkView.append(Html.fromHtml("<a href='" + url + "'>" + title + "</a>"));

    // Populate the image view
    try {//from w w  w  . j a va 2  s .co  m
        imageView = new ImageView(getContext());
        imageView.setPadding(4, 4, 4, 0);
        fetchDrawableOnThread(thumbnailURL, imageView);
        super.addView(imageView);
    } catch (Exception e) {
        Toast.makeText(getContext(), "An error occurred retrieving the video thumbnail", Toast.LENGTH_LONG)
                .show();
    }
    super.addView(linkView);
}

From source file:com.phonegap.plugins.Toaster.java

private void ShowToast(String text) {
    Toast.makeText(this.cordova.getActivity(), text, Toast.LENGTH_LONG).show();
}

From source file:org.kepennar.android.client.social.twitter.TwitterDirectMessageActivity.java

private void showResult(String result) {
    Toast.makeText(this, result, Toast.LENGTH_LONG).show();
}

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

@Override
public void onBackPressed() {

    //Send a request for close the active user session
    _piggate.RequestCloseSession().setListenerRequest(new Piggate.PiggateCallBack() {

        //Method onComplete for JSONObject
        @Override//  w w w  .j  av  a2 s.  com
        public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {
            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
        }

        //Method onError for JSONObject. Uses the reload() method for the Piggate object
        @Override
        public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
            _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();
    super.onBackPressed();
}

From source file:com.piggate.samples.PiggateLoginService.Activity_Logged.java

@Override
public void onBackPressed() {
    _piggate.RequestCloseSession().setListenerRequest(new Piggate.PiggateCallBack() {

        //Send a request for close the active user session
        @Override/*from   w  ww .  j  a  v  a2  s .co  m*/
        public void onComplete(int statusCode, Header[] headers, String msg, JSONObject data) {
            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
        }

        //Method onError for JSONObject. Uses the reload() method for the Piggate object
        @Override
        public void onError(int statusCode, Header[] headers, String msg, JSONObject data) {
            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
            _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();
    super.onBackPressed();
}