working on it ...


Explore Public Snippets

Sort by

Found 10 snippets

    public by AlexZezekalo  1036  0  5  0

    Potential NPE

    //public boolean isSatisfiedBy(T candidate) {
    //return left.isSatisfiedBy(candidate) && right.isSatisfiedBy(candidate);
    //потенциальный NPE   
    //Nonnull as solvation?
    public class AndSpecification<T> extends CompositeSpecification<T> {
        private final Specification<T> left;
        private final Specification<T> right;
        public AndSpecification(@Nonnull Specification<T> left, @Nonnull Specification<T> right) {
            this.left = left;
            this.right = right;
        public boolean isSatisfiedBy(T candidate) {
            return left.isSatisfiedBy(candidate) && right.isSatisfiedBy(candidate);

    public by Tech_JA  2215  0  6  0

    Get resource's name with resource's id

    getResources().getResourceName(int item_id);
    String resource_name = getResources().getResourceName(item_id);
    Log.d("TEST", resource_name);

    public by Tech_JA  2306  3  6  0


    snippet to ceate feedback messages in Android
    //show the text notification for a short period of time 
    Toast.makeText(getApplicationContext(), "my message", Toast.LENGTH_SHORT).show();
    //show the text notification for a long period of time 
    Toast.makeText(getApplicationContext(), "my message", Toast.LENGTH_LONG).show();
    //more info:

    public by Tech_JA  2283  0  6  0

    Open new activity

    Intent i = new Intent(getApplicationContext(), nextscreen.class);

    public by Tech_JA  2200  1  6  0

    How to check if EditText is empty

    //replace txtID with your EditText id
    if (txtID.getText().toString().trim().length()==0]{
      //enter your code

    public by Tech_JA  2204  3  6  2


    how to create feedback messages
    //toast message
    Toast toast = Toast.makeText(getApplicationContext(),
      "your text",Toast.LENGTH_LONG);;                                    

    public by Tech_JA  3315  2  7  2

    Select layout with

    Code do select other layout when click on button
      //Code for layout
      android:onClick="GoOtherLayout" /> // put this line in the button wich you want to use it to select other layout
      //Code for for source
          public void GoOtherLayout(View view){
          setContentView(R.layout.OtherLayout); //change OtherLayout for the layout's name to display

    public by Tech_JA  2391  1  6  1

    Send a log message

    Code to send logs to output to help debugging
    Log.e("error!", "Put here the error!");
    Log.w("warn!", "Put here the warn!");
    Log.i("info!", "Put here the info!");
    Log.d("debug!", "Put here the debug!");
    Log.v("verbose!", "Put here de verbose!");
    //more info at            

    public by Tech_JA  2029  2  6  1

    Avoid software crashes

    How to test your code and, if it got an error, display it and send it to LogCat
    //put your code here
    }catch (Exception e)
      Log.e("Error!", "The error code is: " + e);
      Toast toast = Toast.makeText(getApplicationContext(), "Error:\n"+e,Toast.LENGTH_LONG);; 

    public by Tech_JA  3755  0  6  1

    Alert Dialog

    How to create an alert dialog with AlertDialog class
    //alert dialog
    Builder AlertDiag = new AlertDialog.Builder(this);
    AlertDiag.setMessage("your message");
    AlertDiag.setNeutralButton("OK", null);;            

    List Complete ( 10 snippets total )

    • Public Snippets
    • Channels Snippets