-1

I am trying to send MMS using intent.

Here is my code:

private void sendMmsUsingIntent() throws Exception
{
    Intent sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
    sendIntent.putExtra("address", "1213123123");
    sendIntent.putExtra("sms_body", "some text"); 
    sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/DCIM/Camera/logo.png"));
    sendIntent.setType("image/png");

    //startActivity(sendIntent);
    startActivity(Intent.createChooser(sendIntent,"MMS"));                        
}

I the above code i have hard coded a file name(logo.png) , I want to remove this dependency can any one pleases help me how to do this?

I want to change it like at certain location in the sdcard card whatever media file are available those i can pick randomly one at a time.`

I followed below one but could not get success

'How to display files on the SD card in a ListView?'

Thanks

Community
  • 1
  • 1

1 Answers1

1

I'm not sure what you exactly need, but here are a few options.

1) If you need the external directory folder then use Environment's getExternalStorageDirectory() method.

2) If you require the default ImageDirectory then use Environment's getExternalStoragePublicDirectory() method and pass DIRECTORY_DCIM as a param

Check http://developer.android.com/reference/android/os/Environment.html

EDIT:

Once you have the path of the external directory do something like this:

File f=Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File[] allFiles=   f.listFiles(); //All files and folder
for (int i = 0; i < allFiles.length; i++) {
      if (allFiles[i].isFile()) {
        //Do what you want
      } 
    }
humblerookie
  • 4,717
  • 4
  • 25
  • 40
  • What i want is to replace this code "Uri.parse("file:///sdcard/DCIM/Camera/logo.png"))" with generic code . i mean instead of hoarding the "logo.png" , i want to get the rest of the images which are there in the /sdcard/DCIM/Camera one by one – user1362796 Oct 13 '14 at 07:14