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 writeFile(View view) {
    if (isExternalStorageWritable()) {
        try {/*ww w .j ava2s .c o m*/
            File textFile = new File(Environment.getExternalStorageDirectory(), FILENAME);
            FileOutputStream fileOutputStream = new FileOutputStream(textFile);
            fileOutputStream.write(mEditText.getText().toString().getBytes());
            fileOutputStream.close();
        } catch (java.io.IOException e) {
            e.printStackTrace();
            Toast.makeText(this, "Error writing file", Toast.LENGTH_LONG).show();
        }
    } else {
        Toast.makeText(this, "Cannot write to External Storage", Toast.LENGTH_LONG).show();
    }
}

From source file:com.vrem.wifianalyzer.navigation.items.ExportItem.java

@Override
public void activate(@NonNull MainActivity mainActivity, @NonNull MenuItem menuItem,
        @NonNull NavigationMenu navigationMenu) {
    String title = getTitle(mainActivity);
    List<WiFiDetail> wiFiDetails = getWiFiDetails();
    if (!dataAvailable(wiFiDetails)) {
        Toast.makeText(mainActivity, R.string.no_data, Toast.LENGTH_LONG).show();
        return;//w w  w  . ja va2  s  . c  om
    }
    String data = getData(wiFiDetails);
    Intent intent = createIntent(title, data);
    Intent chooser = createChooserIntent(intent, title);
    if (!exportAvailable(mainActivity, chooser)) {
        Toast.makeText(mainActivity, R.string.export_not_available, Toast.LENGTH_LONG).show();
        return;
    }
    try {
        mainActivity.startActivity(chooser);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(mainActivity, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
    }
}

From source file:com.chess.genesis.activity.Settings.java

@Override
public boolean handleMessage(final Message msg) {
    final JSONObject json = (JSONObject) msg.obj;
    try {/* w w w . j  a v  a2 s . c om*/
        if (json.getString("result").equals("error")) {
            progress.remove();
            Toast.makeText(context, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show();
            return true;
        }
        switch (msg.what) {
        case NetworkClient.GET_OPTION:
            // only emailnote supported
            final CheckBoxPreference email = (CheckBoxPreference) findPreference(
                    Pref.key(context, R.array.pf_emailNoteEnabled));
            email.setChecked(json.getBoolean("value"));

            progress.remove();
            break;
        case NetworkClient.SET_OPTION:
            progress.remove();
            break;
        case SyncClient.MSG:
            final GameDataDB db = new GameDataDB(context);
            db.recalcYourTurn();
            db.close();
            progress.remove();
            break;
        }
        return true;
    } catch (final JSONException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}

From source file:com.dedipower.portal.android.CreateTicket.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    dialog = new ProgressDialog(this);
    dialog.setMessage("Loading...");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.createticket);

    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();//from w  w  w .  j ava 2  s  . co  m
            if (TicketID == 0) {
                Toast.makeText(CreateTicket.this,
                        "Ticket Creation Failed. Please try again later or email request@dedipower.com",
                        Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(CreateTicket.this, "Ticket Created! Returning to main screen...",
                        Toast.LENGTH_SHORT).show();
                finish();
            }
        }
    };

    final Thread submitTicket = new Thread() {
        public void run() {
            try {
                TicketID = API.CreateTicket(Subject, Message);
            } catch (JSONException e) {
                TicketID = 0;
            }

            handler.sendEmptyMessage(0);
        }
    };

    Button CreateTicketButton = (Button) findViewById(R.id.CreateTicketButton);
    CreateTicketButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.show();
            EditText SubjectET = (EditText) findViewById(R.id.Subject);
            EditText MessageET = (EditText) findViewById(R.id.Message);
            Subject = SubjectET.getText().toString();
            Message = MessageET.getText().toString();

            submitTicket.start();
            /*EditText Subject = (EditText) findViewById(R.id.Subject);
            EditText Message = (EditText) findViewById(R.id.Message);
                    
            try 
            {
            TicketID = API.CreateTicket(Subject.getText().toString() , Message.getText().toString());
            } 
            catch (JSONException e) 
            {
               Toast.makeText(CreateTicket.this, "Ticket Creation Failed. Please try again later or email request@dedipower.com", Toast.LENGTH_LONG).show();
            }
                    
                    
            if(TicketID == 0)
            {
               Toast.makeText(CreateTicket.this, "Ticket Creation Failed. Please try again later or email request@dedipower.com", Toast.LENGTH_LONG).show();
            }
            else
            {
               Toast.makeText(CreateTicket.this, "Ticket Created! Returning to main screen...", Toast.LENGTH_SHORT).show();
               finish();
            }*/
        }
    });
}

From source file:net.networksaremadeofstring.pulsant.portal.CreateTicket.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    dialog = new ProgressDialog(this);
    dialog.setMessage("Loading...");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.createticket);

    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();//from w  w  w . j  ava 2s.  c o  m
            if (TicketID == 0) {
                Toast.makeText(CreateTicket.this,
                        "Ticket Creation Failed. Please try again later or email request@Pulsant.com",
                        Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(CreateTicket.this, "Ticket Created! Returning to main screen...",
                        Toast.LENGTH_SHORT).show();
                finish();
            }
        }
    };

    final Thread submitTicket = new Thread() {
        public void run() {
            try {
                TicketID = API.CreateTicket(Subject, Message);
            } catch (JSONException e) {
                TicketID = 0;
            }

            handler.sendEmptyMessage(0);
        }
    };

    Button CreateTicketButton = (Button) findViewById(R.id.CreateTicketButton);
    CreateTicketButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.show();
            EditText SubjectET = (EditText) findViewById(R.id.Subject);
            EditText MessageET = (EditText) findViewById(R.id.Message);
            Subject = SubjectET.getText().toString();
            Message = MessageET.getText().toString();

            submitTicket.start();
            /*EditText Subject = (EditText) findViewById(R.id.Subject);
            EditText Message = (EditText) findViewById(R.id.Message);
                    
            try 
            {
            TicketID = API.CreateTicket(Subject.getText().toString() , Message.getText().toString());
            } 
            catch (JSONException e) 
            {
               Toast.makeText(CreateTicket.this, "Ticket Creation Failed. Please try again later or email request@Pulsant.com", Toast.LENGTH_LONG).show();
            }
                    
                    
            if(TicketID == 0)
            {
               Toast.makeText(CreateTicket.this, "Ticket Creation Failed. Please try again later or email request@Pulsant.com", Toast.LENGTH_LONG).show();
            }
            else
            {
               Toast.makeText(CreateTicket.this, "Ticket Created! Returning to main screen...", Toast.LENGTH_SHORT).show();
               finish();
            }*/
        }
    });
}

From source file:com.dedipower.portal.android.AddTicketReply.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    ticketid = getIntent().getStringExtra("ticketid");
    dialog = new ProgressDialog(this);
    dialog.setMessage("Loading...");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.addticketreply);

    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();/*from w  w  w  .  j a v a2 s. co  m*/
            if (TicketID == 0) {
                Toast.makeText(AddTicketReply.this,
                        "Ticket Reply Failed. Please try again later or email request@dedipower.com",
                        Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(AddTicketReply.this, "Reply added! Returning to main screen...",
                        Toast.LENGTH_SHORT).show();
                finish();
            }
        }
    };

    final Thread submitReply = new Thread() {
        public void run() {
            try {
                TicketID = API.ReplyToTicket(ticketid, Message);
            } catch (JSONException e) {
                TicketID = 0;
            }

            handler.sendEmptyMessage(0);
        }
    };

    Button AddReplyButton = (Button) findViewById(R.id.AddReplyButton);
    AddReplyButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.show();
            EditText MessageET = (EditText) findViewById(R.id.Message);
            Message = MessageET.getText().toString();

            submitReply.start();
        }
    });
}

From source file:net.networksaremadeofstring.pulsant.portal.AddTicketReply.java

public void onCreate(Bundle savedInstanceState) {
    API.SessionID = getIntent().getStringExtra("sessionid");
    ticketid = getIntent().getStringExtra("ticketid");
    dialog = new ProgressDialog(this);
    dialog.setMessage("Loading...");

    super.onCreate(savedInstanceState);
    setContentView(R.layout.addticketreply);

    final Handler handler = new Handler() {
        public void handleMessage(Message msg) {
            dialog.dismiss();// ww w . j a v  a  2 s .c  o  m
            if (TicketID == 0) {
                Toast.makeText(AddTicketReply.this,
                        "Ticket Reply Failed. Please try again later or email request@Pulsant.com",
                        Toast.LENGTH_LONG).show();
            } else {
                Toast.makeText(AddTicketReply.this, "Reply added! Returning to main screen...",
                        Toast.LENGTH_SHORT).show();
                finish();
            }
        }
    };

    final Thread submitReply = new Thread() {
        public void run() {
            try {
                TicketID = API.ReplyToTicket(ticketid, Message);
            } catch (JSONException e) {
                TicketID = 0;
            }

            handler.sendEmptyMessage(0);
        }
    };

    Button AddReplyButton = (Button) findViewById(R.id.AddReplyButton);
    AddReplyButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            dialog.show();
            EditText MessageET = (EditText) findViewById(R.id.Message);
            Message = MessageET.getText().toString();

            submitReply.start();
        }
    });
}

From source file:com.ce.skuniv.waypoints.ComunityMap.java

public void send(double selectedLatitude, double selectedLongitude, String nick, String description) {

    String data = format.format(selectedLatitude / 1e6) + ";" + format.format(selectedLongitude / 1e6) + ";"
            + MyBase64.encode(nick.getBytes()) + ";" + MyBase64.encode(description.getBytes());
    try {/* ww  w.  j  ava2  s.  c  o  m*/
        execute(data);
        Log.d("aaa", "Added to comunity map");
        Toast.makeText(context, "Point added to map", Toast.LENGTH_LONG).show();
    } catch (Exception e) {
        Log.d("aaa", "Comunity map error " + e.getMessage());
        Toast.makeText(context, "Error", Toast.LENGTH_LONG).show();

    }
}

From source file:com.example.gcmandroid.GcmService.java

private void sendNotification(final String msg) {
    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {
        @Override/*from   w  w  w .  j a  va 2  s  .  c o m*/
        public void run() {
            Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
            if (MainActivity.mTextView != null) {
                MainActivity.mTextView.setText(msg);
            }
        }
    });
}

From source file:com.eyekabob.AddBand.java

public void submit(View v) {
    Spinner genreSpinner = (Spinner) findViewById(R.id.genreSpinner);
    EditText nameEditText = (EditText) findViewById(R.id.artistNameEditText);
    EditText urlEditText = (EditText) findViewById(R.id.urlEditText);
    EditText bioEditText = (EditText) findViewById(R.id.artistDescriptionEditText);

    String genre = (String) genreSpinner.getSelectedItem();
    String name = nameEditText.getText().toString();
    String url = urlEditText.getText().toString();
    String bio = bioEditText.getText().toString();

    if (getResources().getString(R.string.genre).equals(genre)) {
        // TODO: make better validation message.
        Toast.makeText(this, "Select a genre", Toast.LENGTH_LONG).show();
        return;/*from   www.  j a  va2 s .c  o m*/
    }

    if (name == null || "".equals(name.trim())) {
        Toast.makeText(this, "Enter artist name", Toast.LENGTH_LONG).show();
        return;
    }

    Map<String, String> params = new HashMap<String, String>();
    params.put("genre", genre);
    params.put("name", name);
    params.put("url", url);
    params.put("bio", bio);
    Uri uri = EyekabobHelper.WebService.getURI("artist", "addArtist", params);
    new AddArtistTask().execute(uri);
}