Friday, 23 November 2012

How to send email and How to get the user conformation in Android

Hi,

     I am sending the email by using an intent. How can I get confirmation that the email has sent or there has been an error back into the activity it was called from??
    This is my sample code....

  send.setOnClickListener(new OnClickListener() {
                                                             //    @Override
 public void onClick(View v) {
                                                                         
 RelativeLayout lila1 = (RelativeLayout) findViewById(R.id.relativeLayout2);
 lila1.removeAllViews(); // if you want to empty it
 lila1.setVisibility(8);
                                                                                        
rl = (RelativeLayout)findViewById(R.id.Home_relativelayout);
 View v1 = rl.getRootView();
 //    setDrawingCacheEnabled(true);
 v1.setDrawingCacheEnabled(true);
  final Bitmap bm = v1.getDrawingCache();

  String path = Images.Media.insertImage(getContentResolver(), bm, "title", null);
                                                                                                  
  Uri bUri= Uri.parse(path);                            
 Intent sendIntent;
 sendIntent = new Intent(Intent.ACTION_SEND);
                                                                                          sendIntent.putExtra(android.content.Intent.EXTRA_EMAIL,"");
                                                                        sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test");
                                                                                                sendIntent.putExtra(android.content.Intent.EXTRA_STREAM,bUri);
                                                                                 sendIntent.setType("image/png");
                                                                                                sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hy Testing");
                                                                                startActivity(Intent.createChooser(sendIntent, "Send Mail"));
                                                                         

Toast.makeText(getApplicationContext(), "Image"+(pos+1),Toast.LENGTH_SHORT).show();
                                                                         
     }
  });
                                                             

 }

Here I need to do something on a successfully sent ........

Here using May be Start ActivityForResult ???

      Please Suggest me.....


No comments:

Post a Comment