Page 516 - 3-2
P. 516

Button button = (Button)findViewById(R.id.button1);


                    button.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {


                         Toast.makeText(getApplicationContext(),                            " 저장되었습니다.",
            Toast.LENGTH_LONG).show();
                            try{
                                MediaStore.Images.Media.insertImage(getContentResolver(),      bm,     "title",
            "descripton");
                      sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://sdcard"+
            Environment.getExternalStorageDirectory())));
            }catch(Exception e){};
                        }
                    });




                }


            //url  통신 &  갤러리 저장
                private class Back extends AsyncTask <String, Integer,Bitmap>{




                    @Override
                    protected Bitmap doInBackground(String... urls) {
                        // TODO Auto-generated method stub
                        try{
                            ;




                            URL myFileUrl = new URL(urls[0]);
                            HttpURLConnection conn = (HttpURLConnection)myFileUrl.openConnection();
                            conn.setDoInput(true);
                            conn.connect();


                            InputStream is = conn.getInputStream();


                            bm = BitmapFactory.decodeStream(is);


                            FileOutputStream                   fos                   =                   new
            FileOutputStream(Environment.getExternalStorageDirectory().toString()+"now.png");
                            bm.compress(Bitmap.CompressFormat.PNG, 100 , fos);
                            fos.flush();


                                                         - 516 -
   511   512   513   514   515   516   517   518   519   520   521