I want to take screenshot in my android activity through a program so that when a user click on a button to take a screenshot, the screenshot shoudl be saved in SD card. I am adding the following code and facing some errors.In eclipse the package name in code is underlined with red line TOSTRING(com.meri.meri_application).
    public class PartySalesandRecovery extends Activity implements OnClickListener{
     UserFunctions userFunction;
     DatabaseHandler db;
     String str;
     String moneyString2,moneyString3,moneyString4,moneyString5,moneyString6,moneyString7;
     String month,loginName,week;
     ImageView imageView;
      Bitmap bmp;
     int orientation;
     int total_sale_trg = 0;
     int total_sale_act = 0;
     int total_rec_trg = 0;
     int total_rec_act = 0;
     int total_per_sale = 0;
     int total_per_rec = 0;
     private static String KEY_SUCCESS = "success";
         TableLayout tl;
         LayoutParams lp;
         Spinner quesWeek,quesMonth;
         Button btnShow,btnTakeScreen;
         JSONObject json,json_user;
          private View view;
         @Override
         protected void onCreate(Bundle savedInstanceState) {
       // TODO Auto-generated method stub
         super.onCreate(savedInstanceState);
          setContentView(R.layout.partysalesandrecovery);
          view= findViewById(R.id.screenRoot);
          orientation = this.getResources().getConfiguration().orientation;
          Calendar cal=Calendar.getInstance();
          SimpleDateFormat month_date = new SimpleDateFormat("MMMMMMMMM");
          String month_name = month_date.format(cal.getTime());
          quesMonth = (Spinner)findViewById(R.id.comboMonth);
          quesWeek = (Spinner)findViewById(R.id.comboWeek);
          ArrayAdapter myAdap = (ArrayAdapter) quesMonth.getAdapter();
          int spinnerPosition = myAdap.getPosition(month_name);
          quesMonth.setSelection(spinnerPosition);
          tl = (TableLayout)findViewById(R.id.tableLayoutLocationSaleandRecovery);
          btnShow = (Button)findViewById(R.id.btnShowReports);
          btnShow.setOnClickListener(this);
          btnTakeScreen = (Button)findViewById(R.id.btnTakeScreenShot);
          btnTakeScreen.setOnClickListener(this);
        }
///////////////////////////////
///////////////////////////////////////
        public void saveBitmap(Bitmap bitmap) {
        try {
          ByteArrayOutputStream bytes = new ByteArrayOutputStream();
          bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
          File f = new File(Environment.getExternalStorageDirectory()
                + File.separator + "test.jpg");
          f.createNewFile();
          FileOutputStream fo = new FileOutputStream(f);
          fo.write(bytes.toByteArray());
          fo.close();
        } catch (FileNotFoundException e) {
          Log.e("GREC", e.getMessage(), e);
         }catch (IOException e) {
          Log.e("GREC", e.getMessage(), e);
        }
        }
////////////////////////////////
         @Override
        public void onClick(View v) {
        // TODO Auto-generated method stub
         if(v.getId()==R.id.btnTakeScreenShot)
        {
        Bitmap bitmap = Bitmap.createBitmap(500, 500, Bitmap.Config.ALPHA_8);
        View from = (LinearLayout)findViewById(R.id.viewRoot);
        Bitmap result = drawViewToBitmap(from, bitmap);
        imageView = (ImageView)findViewById(R.id.imgViewpic);
        imageView.setImageBitmap(result);
        saveBitmap(bitmap);
        try 
        {
        imageView.setDrawingCacheEnabled(true);
        bmp = Bitmap.createBitmap(imageView.getDrawingCache());
        imageView.setDrawingCacheEnabled(false);
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        bmp.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
        File f = new File(Environment.getExternalStorageDirectory()
                                + File.separator + "test.jpg");
        f.createNewFile();
        FileOutputStream fo = new FileOutputStream(f);
        fo.write(bytes.toByteArray()); 
        fo.close();
         } catch (Exception e) {
            // TODO Auto-generated catch block
        e.printStackTrace();
        Toast.makeText(this, e.getMessage(), 7000).show();
          } 
           }
                code of XML
   <?xml version="1.0" encoding="utf-8"?>
  <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/viewRoot" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        >
    <Spinner 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/comboMonth"
        android:prompt="@string/month_prompt"
        android:entries="@array/question_months"
        android:layout_weight="0.5"
        />
    <Spinner 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/comboWeek"
        android:entries="@array/question_weeks"
        android:prompt="@string/week_prompt"
        android:layout_weight="0.5"
        />
    </LinearLayout>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Show Reports"
        android:id="@+id/btnShowReports"
        />
    <View
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="#000000"
        />
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Projects Sales and Recovery Status"
        android:textSize="16sp"
        android:textStyle="bold"
        android:gravity="center"
        />
    <TableLayout
        android:id="@+id/tableLayoutLocationSaleandRecovery"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:shrinkColumns="*"
        android:stretchColumns="*" >
    </TableLayout>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Capture"
        android:layout_gravity="right"
        android:id="@+id/btnTakeScreenShot"
        />
    <ImageView
        android:id="@+id/imgViewpic"
        android:layout_width="250dp"
        android:layout_height="250dp"
        android:src="@drawable/ic_launcher"
        android:layout_gravity="center"
        android:visibility="invisible" />
    </LinearLayout>
    </ScrollView>
 
     
     
    