Example usage for android.widget Toast show

List of usage examples for android.widget Toast show

Introduction

In this page you can find the example usage for android.widget Toast show.

Prototype

public void show() 

Source Link

Document

Show the view for the specified duration.

Usage

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();/*from  w w w. j  a v a  2s. co 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);
        }
    }
}

From source file:com.robertszkutak.androidexamples.tumblrexample.TumblrExampleActivity.java

@Override
public void onResume() {
    super.onResume();

    if (auth == false) {
        if (browser == true)
            browser2 = true;//from www  .j  a va2 s.co  m

        if (browser == false) {
            browser = true;
            newIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(authURL));
            startActivity(newIntent);
        }

        if (browser2 == true) {
            Uri uri = getIntent().getData();
            uripath = uri.toString();

            if (uri != null && uripath.startsWith(OAUTH_CALLBACK_URL)) {
                String verifier = uri.getQueryParameter(OAuth.OAUTH_VERIFIER);
                try {

                    provider.retrieveAccessToken(consumer, verifier);

                    token = consumer.getToken();
                    secret = consumer.getTokenSecret();

                    final Editor editor = pref.edit();
                    editor.putString("TUMBLR_OAUTH_TOKEN", token);
                    editor.putString("TUMBLR_OAUTH_TOKEN_SECRET", secret);
                    editor.commit();

                    auth = true;
                    loggedin = true;

                } catch (OAuthMessageSignerException e) {
                    e.printStackTrace();
                } catch (OAuthNotAuthorizedException e) {
                    e.printStackTrace();
                } catch (OAuthExpectationFailedException e) {
                    e.printStackTrace();
                } catch (OAuthCommunicationException e) {
                    e.printStackTrace();
                }
            }
        }
    } else {
        setContentView(R.layout.main);

        blogname = (EditText) findViewById(R.id.blogname);
        posttitle = (EditText) findViewById(R.id.posttitle);
        poststring = (EditText) findViewById(R.id.post);
        debugStatus = (TextView) findViewById(R.id.debug_status);
        post = (Button) findViewById(R.id.btn_post);
        loginorout = (Button) findViewById(R.id.loginorout);

        blogname.setText(pref.getString("TUMBLR_BLOG_NAME", ""));

        debug = "Access Token: " + token + "\n\nAccess Token Secret: " + secret;
        debugStatus.setText(debug);

        post.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                if (isAuthenticated()) {
                    saveBlogName();
                    sendPost();
                } else {
                    Toast toast = Toast.makeText(getApplicationContext(), "You are not logged into Tumblr",
                            Toast.LENGTH_SHORT);
                    toast.show();
                }
            }
        });

        loginorout.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                LogInOrOut();
            }
        });

        updateLoginStatus();
    }

    if (auth == false && browser2 == true)
        finish();
}

From source file:com.filelocker.andy.MainActivity.java

public void lockButton_Click(View view) {

    TextView vPasswordText = (TextView) findViewById(R.id.passwordText);
    TextView vFileChooserText = (TextView) findViewById(R.id.fileChooserText);

    String myPassword = vPasswordText.getText().toString();

    vPasswordText.setText("");

    if (vFileChooserText.getText().toString().equals("") || myPassword.equals("")) {
        Toast toast;
        if (vFileChooserText.getText().toString().equals("")) {
            toast = Toast.makeText(getApplicationContext(), "File Not Choosen", Toast.LENGTH_LONG);
            toast.show();
        } else if (myPassword.equals("")) {
            toast = Toast.makeText(getApplicationContext(), "Password Field Empty", Toast.LENGTH_LONG);
            toast.show();//from www  .  java  2 s.c  o  m
        }

        return;
    } else if (!(vFileChooserText.getText().toString()
            .substring(vFileChooserText.getText().toString().lastIndexOf('.') + 1).equals("encrypt"))) {

        AES_Encryption en = new AES_Encryption(myPassword);
        /*
         * setup encryption cipher using password. print out iv and salt
         */
        try {
            File vInFile = new File(vFileChooserText.getText().toString());

            if (vInFile.exists() == false) {
                throw new FileNotFoundException("File Not Found");
            }

            en.setupEncrypt();
        } catch (InvalidKeyException ex) {
            ex.printStackTrace();
        } catch (NoSuchAlgorithmException ex) {
            ex.printStackTrace();
        } catch (InvalidKeySpecException ex) {
            ex.printStackTrace();
        } catch (NoSuchPaddingException ex) {
            ex.printStackTrace();
        } catch (InvalidParameterSpecException ex) {
            ex.printStackTrace();
        } catch (IllegalBlockSizeException ex) {
            ex.printStackTrace();
        } catch (BadPaddingException ex) {
            ex.printStackTrace();
        } catch (UnsupportedEncodingException ex) {
            ex.printStackTrace();
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }

        /*
         * write out encrypted file
         */
        try {

            File vInFile = new File(vFileChooserText.getText().toString());
            File vOutFile = new File(vFileChooserText.getText().toString() + ".encrypt");

            if (vInFile.exists() == false) {
                throw new FileNotFoundException("File Not Found");
            }

            en.WriteEncryptedFile(vInFile, vOutFile);

            Toast toast = Toast.makeText(getApplicationContext(), "Encryption Complete", Toast.LENGTH_LONG);
            toast.show();
            vInFile.delete();

        } catch (IllegalBlockSizeException ex) {
            ex.printStackTrace();
        } catch (BadPaddingException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    } else {

        /*
         * decrypt file
         */
        AES_Encryption dc = new AES_Encryption(myPassword);
        try {
            File vInFile = new File(vFileChooserText.getText().toString());

            if (vInFile.exists() == false) {
                throw new FileNotFoundException("File Not Found");
            }

            dc.setupDecrypt(vInFile);
        } catch (InvalidKeyException ex) {
            ex.printStackTrace();
        } catch (NoSuchAlgorithmException ex) {
            ex.printStackTrace();
        } catch (InvalidKeySpecException ex) {
            ex.printStackTrace();
        } catch (NoSuchPaddingException ex) {
            ex.printStackTrace();
        } catch (InvalidAlgorithmParameterException ex) {
            ex.printStackTrace();
        } catch (DecoderException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {

            ex.printStackTrace();
        }

        /*
         * write out decrypted file
         */
        try {
            File vInFile = new File(vFileChooserText.getText().toString());
            File vOutFile = new File(vFileChooserText.getText().toString().substring(0,
                    vFileChooserText.getText().toString().length() - 8));

            if (vInFile.exists() == false) {
                throw new FileNotFoundException("File Not Found");
            }

            dc.ReadEncryptedFile(vInFile, vOutFile);
            vInFile.delete();

            Toast toast = Toast.makeText(getApplicationContext(), "Decryption Complete", Toast.LENGTH_LONG);
            toast.show();
        } catch (IllegalBlockSizeException ex) {
            ex.printStackTrace();
        } catch (BadPaddingException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

}

From source file:net.stefanopallicca.android.awsmonitor.MainActivity.java

/**
 * Called when {@code SettingsActivity} is closed.
 *///w  w w  .  j av a 2s . c om
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    context = getApplicationContext();
    if (requestCode == 1) {
        if (resultCode == RESULT_OK) {
            String regid = getRegistrationId(this);
            server = new GsnServer(_sharedPref.getString("pref_server_url", ""),
                    Integer.parseInt(_sharedPref.getString("pref_server_port", "")));
            if (regid != "") {
                boolean regOk;
                Context context = getApplicationContext();
                CharSequence text = "";
                try {
                    regOk = server.sendRegistrationIdToBackend(regid);
                    if (regOk) {
                        text = getString(R.string.device_registered) + " "
                                + MainActivity.this._sharedPref.getString("pref_server_url", "") + ":"
                                + MainActivity.this._sharedPref.getString("pref_server_port", "");
                    } else {
                        text = getString(R.string.error_connecting) + " "
                                + MainActivity.this._sharedPref.getString("pref_server_url", "") + ":"
                                + MainActivity.this._sharedPref.getString("pref_server_port", "");
                    }
                } catch (HttpException e) {
                    text = getString(R.string.service_not_found);
                }
                int duration = Toast.LENGTH_LONG;

                Toast toast = Toast.makeText(context, text, duration);
                toast.show();

                launchMainApp();
            } else {
                registerInBackground();
            }

        }
        if (resultCode == RESULT_CANCELED) {
        }
    }
}

From source file:com.ritul.truckshare.RegisterActivity.DriverLicenseActivity.java

public void Image_Selecting_Task(Intent data) {
    try {/*from ww  w.ja  v  a2 s. co  m*/
        Utility.uri = data.getData();
        if (Utility.uri != null) {
            // User had pick an image.
            Cursor cursor = getContentResolver().query(Utility.uri,
                    new String[] { android.provider.MediaStore.Images.ImageColumns.DATA }, null, null, null);
            cursor.moveToFirst();
            // Link to the image
            final String imageFilePath = cursor.getString(0);

            //Assign string path to File
            Utility.Default_DIR = new File(imageFilePath);

            // Create new dir MY_IMAGES_DIR if not created and copy image into that dir and store that image path in valid_photo
            Utility.Create_MY_IMAGES_DIR();

            // Copy your image
            Utility.copyFile(Utility.Default_DIR, Utility.MY_IMG_DIR);

            // Get new image path and decode it
            Bitmap b = Utility.decodeFile(Utility.Paste_Target_Location);

            // use new copied path and use anywhere
            String valid_photo = Utility.Paste_Target_Location.toString();
            b = Bitmap.createScaledBitmap(b, 150, 150, true);

            //set your selected image in image view
            preview.setImageBitmap(b);
            cursor.close();

        } else {
            Toast toast = Toast.makeText(this, "Sorry!!! You haven't selecet any image.", Toast.LENGTH_LONG);
            toast.show();
        }
    } catch (Exception e) {
        // you get this when you will not select any single image
        Log.e("onActivityResult", "" + e);

    }
}

From source file:br.com.GUI.perfil.PerfilAluno.java

private void cortar(int requestCode) {
    //take care of exceptions
    try {//from   w  ww .  j a v a  2 s.  c om
        //call the standard crop action intent (the user device may not support it)
        Intent cropIntent = new Intent("com.android.camera.action.CROP");
        //indicate image type and Uri
        cropIntent.setDataAndType(selectedImageUri, "image/*");
        //set crop properties
        cropIntent.putExtra("crop", "true");
        //indicate aspect of desired crop
        cropIntent.putExtra("aspectX", 1);
        cropIntent.putExtra("aspectY", 1);
        //indicate output X and Y
        cropIntent.putExtra("outputX", 144);
        cropIntent.putExtra("outputY", 144);
        //retrieve data on return
        cropIntent.putExtra("return-data", true);
        //start the activity - we handle returning in onActivityResult
        startActivityForResult(cropIntent, requestCode + 2);
    }
    //respond to users whose devices do not support the crop action
    catch (ActivityNotFoundException anfe) {
        //display an error message
        String errorMessage = "Whoops - your device doesn't support the crop action!";
        Toast toast = Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_SHORT);
        toast.show();
    }
}

From source file:alaindc.memenguage.View.MainActivity.java

private void updateWordsList() {
    wordsListview = (ListView) findViewById(R.id.wordslistview);

    adapter = new WordsAdapter(this, crs, 0);

    adapter.setFilterQueryProvider(new FilterQueryProvider() {
        public Cursor runQuery(CharSequence constraint) {
            return dbmanager.getMatchingWords(String.valueOf(constraint));
        }//from  ww  w  . ja  va2  s .com
    });

    wordsListview.setAdapter(adapter);
    wordsListview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int pos, long id) {
            Intent createWordIntentActivity = new Intent(MainActivity.this, CreateEditActivity.class);
            createWordIntentActivity.setAction(Constants.ACTION_EDIT_WORD);

            Cursor crs = (Cursor) arg0.getItemAtPosition(pos);
            createWordIntentActivity.putExtra(Constants.EXTRA_EDIT_ITA,
                    crs.getString(crs.getColumnIndex(Constants.FIELD_ITA)));
            createWordIntentActivity.putExtra(Constants.EXTRA_EDIT_ENG,
                    crs.getString(crs.getColumnIndex(Constants.FIELD_ENG)));
            createWordIntentActivity.putExtra(Constants.EXTRA_EDIT_ID, id);

            MainActivity.this.startActivity(createWordIntentActivity);
            return true;
        }
    });

    wordsListview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long id) {
            crs = (Cursor) arg0.getItemAtPosition(pos);
            String text = "Memory level: " + crs.getInt(crs.getColumnIndex(Constants.FIELD_RATING)) + "/5";
            text = text + "\nLast edit: "
                    + Utils.getDate(crs.getLong(crs.getColumnIndex(Constants.FIELD_TIMESTAMP)));

            crs = dbmanager.getContextById(id);
            if (crs != null && crs.getCount() > 0) {
                crs.moveToFirst();
                String cont = crs.getString(crs.getColumnIndex(Constants.FIELD_CONTEXT));
                text = text + "\n\n" + ((cont.equals("")) ? "Add a context sentence" : "Context:\n" + cont);
            }

            Toast t = Toast.makeText(getApplicationContext(), text, Toast.LENGTH_LONG);
            t.setGravity(Gravity.TOP, 0, 250);
            t.show();
        }
    });

    //Toast.makeText(getApplicationContext(), adapter.getCount()+" words in Memenguage", Toast.LENGTH_SHORT).show();
}

From source file:com.lance.commu.fragment.BaseActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    System.out.println("base onCreate ");
    // set the Behind View
    setBehindContentView(R.layout.menu_frame);
    if (savedInstanceState == null) {
        FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
        mFrag = new MenuListFragment();
        t.replace(R.id.menu_frame, mFrag);
        t.commit();/*ww w  .j av  a 2s  .c o  m*/
    } else {
        mFrag = (ListFragment) this.getSupportFragmentManager().findFragmentById(R.id.menu_frame);
    }
    // customize the SlidingMenu  
    SlidingMenu sm = getSlidingMenu();
    sm.setShadowWidthRes(R.dimen.shadow_width);
    sm.setShadowDrawable(R.drawable.shadow);
    sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    sm.setFadeDegree(0.35f);
    sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    sm.setBehindOffset(400);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ////////////////////////////////////////
    connect = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); //  
    requestURL1 = "http://121.157.84.63:8080/lance/androidFriendList.jsp"; //    

    //       
    //  OracleDB    
    //   ListView   
    getContactData();

    //Sqlite DB  
    //Oracle DB   Sqlite  
    //     Oracle DB   
    //Sqlite     
    //      Oracle DB  Sqlite 
    try {
        db_Handler = DB_Handler.open(this);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        System.out.println("db open ");
    }

    //       
    //Oracle DB  
    if (connect.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED
            || connect.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
                    .getState() == NetworkInfo.State.CONNECTED) {
        if (flag == true) {
            new Networking1().execute();
            System.out.println(" ");
            flag = false; //          
                          // Sqlite ListView  
        }

    }

    else {
        Toast toast = Toast.makeText(BaseActivity.this, " ", Toast.LENGTH_SHORT);
        toast.show();
    }

    System.out.println("base onCreate ");
}

From source file:fm.smart.r1.activity.CreateExampleActivity.java

public void onClick(View v) {
    EditText exampleInput = (EditText) findViewById(R.id.create_example_sentence);
    EditText translationInput = (EditText) findViewById(R.id.create_example_translation);
    EditText exampleTransliterationInput = (EditText) findViewById(R.id.sentence_transliteration);
    EditText translationTransliterationInput = (EditText) findViewById(R.id.translation_transliteration);
    final String example = exampleInput.getText().toString();
    final String translation = translationInput.getText().toString();
    if (TextUtils.isEmpty(example) || TextUtils.isEmpty(translation)) {
        Toast t = Toast.makeText(this, "Example and translation are required fields", 150);
        t.setGravity(Gravity.CENTER, 0, 0);
        t.show();
    } else {// w w w .ja  va2  s.  co  m
        final String example_language_code = Utils.LANGUAGE_MAP.get(example_language);
        final String translation_language_code = Utils.LANGUAGE_MAP.get(translation_language);
        final String example_transliteration = exampleTransliterationInput.getText().toString();
        final String translation_transliteration = translationTransliterationInput.getText().toString();

        if (Main.isNotLoggedIn(this)) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setClassName(this, LoginActivity.class.getName());
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid
            // navigation
            // back to this?
            LoginActivity.return_to = CreateExampleActivity.class.getName();
            LoginActivity.params = new HashMap<String, String>();
            LoginActivity.params.put("list_id", list_id);
            LoginActivity.params.put("item_id", item_id);
            LoginActivity.params.put("example", example);
            LoginActivity.params.put("translation", translation);
            LoginActivity.params.put("example_language", example_language);
            LoginActivity.params.put("translation_language", translation_language);
            LoginActivity.params.put("example_transliteration", example_transliteration);
            LoginActivity.params.put("translation_transliteration", translation_transliteration);
            startActivity(intent);
        } else {

            final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
            myOtherProgressDialog.setTitle("Please Wait ...");
            myOtherProgressDialog.setMessage("Creating Example ...");
            myOtherProgressDialog.setIndeterminate(true);
            myOtherProgressDialog.setCancelable(true);

            final Thread create_example = new Thread() {
                public void run() {
                    // TODO make this interruptable .../*if
                    // (!this.isInterrupted())*/
                    try {
                        // TODO failures here could derail all ...
                        CreateExampleActivity.add_item_list_result = ItemActivity.addItemToList(list_id,
                                item_id, CreateExampleActivity.this);
                        CreateExampleActivity.create_example_result = createExample(example,
                                example_language_code, example_transliteration, translation,
                                translation_language_code, translation_transliteration, item_id, list_id);
                        CreateExampleActivity.add_sentence_list_result = ItemActivity.addSentenceToList(
                                CreateExampleActivity.create_example_result.http_response, item_id, list_id,
                                CreateExampleActivity.this);
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    myOtherProgressDialog.dismiss();

                }
            };
            myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    create_example.interrupt();
                }
            });
            OnCancelListener ocl = new OnCancelListener() {
                public void onCancel(DialogInterface arg0) {
                    create_example.interrupt();
                }
            };
            myOtherProgressDialog.setOnCancelListener(ocl);
            myOtherProgressDialog.show();
            create_example.start();
        }
    }
}

From source file:es.curso.android.streamingVLC.VideoActivity.java

/*************
 * Player/*  w  w w .ja va2  s.co m*/
 *************/

private void createPlayer(String media) {
    releasePlayer();

    if (media.length() > 0) {
        Toast toast = Toast.makeText(this, media, Toast.LENGTH_LONG);
        toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
        toast.show();
    }

    // Create a new media player
    try {
        libvlc = LibVLC.getInstance();
    } catch (LibVlcException e) {
        Toast.makeText(this, "Can't create player", Toast.LENGTH_LONG).show();
        return;
    }
    libvlc.setIomx(false);
    libvlc.setSubtitlesEncoding("");
    libvlc.setAout(LibVLC.AOUT_OPENSLES);
    libvlc.setTimeStretching(true);
    libvlc.setChroma("RV32");
    libvlc.setVerboseMode(true);
    LibVLC.restart(this);
    EventHandler.getInstance().addHandler(mHandler);
    if (holder == null)
        Log.d(TAG, "holder==null");
    holder.setFormat(PixelFormat.RGBX_8888);
    holder.setKeepScreenOn(true);
    MediaList list = libvlc.getMediaList();
    list.clear();
    list.add(new Media(libvlc, LibVLC.PathToURI(media)), false);
    libvlc.playIndex(0);

}