Skip to main content

Action_Send display popup whatever you required.

 final Intent emailIntent = new Intent(
                                android.content.Intent.ACTION_SEND_MULTIPLE);

                        // Recording file send to mail
                        //emailIntent.setType("image/png");
                        //emailIntent.setType("audio/3gp");
                        emailIntent.putExtra("data", sourceImageBitmap);
                       emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        //emailIntent.setType("application/email");
                        emailIntent.setType("vnd.android.cursor.dir/email");
                        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"user@example.com"});

                        emailIntent.putExtra(
                                android.content.Intent.EXTRA_EMAIL,
                                new String[] { getSharedPreferences(
                                        "emailedittext", 0).getString(
                                        "emailedittext_value", "") });
                        emailIntent.putExtra(
                                android.content.Intent.EXTRA_SUBJECT,
                                "Complaint");
                        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                                "Attached in the mail is the complaint for coordinate"
                                        + "\n" + "latitude "
                                        + issueLatitudeString + "\n"
                                        + "longitude " + issueLongitudeString
                                        + "\n" + "for place "
                                        + issueAddressString );
                       
                        String s = emailIntent.getPackage();
                        emailIntent.putParcelableArrayListExtra(
                                Intent.EXTRA_STREAM, uris);
                   
                        final PackageManager pm = getPackageManager();
                        final List<ResolveInfo> matches = pm
                                .queryIntentActivities(emailIntent, 0);
                        final ResolveInfo[] best = new ResolveInfo[matches
                                .size()];
                        ArrayList<String> emailList = new ArrayList<String>();
                        String space = "    ";
                        itemActivity = 0;
                        for (final ResolveInfo info : matches) {
                            if ( info.activityInfo.applicationInfo.className
                                            .toLowerCase().contains("mail")) {
                                best[itemActivity] = info;
                              
                                String res = info.activityInfo.applicationInfo.className;
                                emailList.add(space
                                        + res.substring(res.lastIndexOf(".") + 1));
                                                                    
                                itemActivity++;
                            }
                        }
                        int i = 0;
                        String item[] = new String[emailList.size()];
                        for (String string : emailList) {
                            item[i++] = string;
                        }
                      
                        if (item[0]!=null) {
                            AlertDialog.Builder builder = new AlertDialog.Builder(
                                    NewIssue.this);
                            builder.setTitle("Pick an item");
                            builder.setIcon(best[0].activityInfo.getIconResource());
                            builder.setItems(item,
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(
                                                DialogInterface dialog, int item) {

                                            emailIntent
                                                    .setClassName(
                                                            best[item].activityInfo.packageName,
                                                            best[item].activityInfo.name);
                                            startActivity(emailIntent);
                                            finish();

                                        }
                                    });
                            //builder.setIcon(best[itemActivity-1].activityInfo.icon);
                            AlertDialog alert = builder.create();
                            alert.show();
                        } else {
                            startActivity(emailIntent);
                        }

Comments

Popular posts from this blog

ProgressDialog example using handler android

final ProgressDialog dialog = ProgressDialog . show ( this , "Title" , "Message" , true ); final Handler handler = new Handler () { public void handleMessage ( Message msg ) { dialog . dismiss (); } } ; Thread t = new Thread () { public void run () { // write process code here. handler . sendEmptyMessage ( 0 ); } } ; t . start ();

How to set image button click effect ?

I have one simple solution: using that, you can set the default press effect to the button. // Create button and add event Button addImageView = (Button) bottomView.findViewById(R.id. addImage ); addImageView.setOnClickListener( new OnClickListener () { @Override public void onClick(View v) { // click event } }); //Using this code set touch listener addImageView.setOnTouchListener( touchEffect ); //touch listner OnTouchListener touchEffect = new OnTouchListener() {         public boolean onTouch(View v, MotionEvent event) {             switch (event.getAction()) {                 case MotionEvent. ACTION_DOWN : {                     v.getBackground().setColorFilter(0xe0f47521,PorterDuff.Mode. SRC_ATOP );                     v....

Store array of String or int or list in SharedPreferences android

 SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences( this );         JSONArray arr = new JSONArray ();         arr.put( "Viren" );         arr.put( "Android" );         prefs.edit().putString( "key" , arr.toString());         prefs.edit().commit();         try {             arr = new JSONArray (prefs.getString( "key" , "{}" ));             System. out .println(arr.getString(1));          } catch ( JSONException e) {             e.printStackTrace();         }