Hi everyone, I am working on a Video App, where you can click on a video from the sdcard. This click event opens a menu (I used a options menu) that provides the user with different sharing options, e.g. email, bluetooth etc. This part works fine so far... What I am now trying to do is, when the user chooses "email" the app should open the email app of the phone via an intent (this also works fine) and should directly attach the video he clicked before to the new email .
The last part is, where I am stuck because I don't know how to tell the app that the video that was clicked before to open the menu should be attached to the mail: Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setType("video/mp4"); i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(Environment.getExternalStorageDirectory(),"DON'T KNOW HOW TO ACCESS THE CLICKE FILENAME"))); startActivity(i); I would appreciate any advice or help. Thank you in advance ...I will post my entire code below... package com.mobilevideoeditor.moved; import java.io.File; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.provider.MediaStore; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.TextView; import android.widget.AdapterView.OnItemClickListener; public class ShareGalleryView extends Activity { private Cursor videocursor; private int video_column_index; int count; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.videogrid); //create new Grid View GridView vGrid=(GridView) findViewById(R.id.vgrid); registerForContextMenu(vGrid); vGrid.setAdapter(new VideoAdapter(this)); init_phone_video_grid(); vGrid.setOnItemClickListener(new OnItemClickListener() { @Override // click on item and open options menu public void onItemClick(AdapterView<?> parent, View v, int position, long id) { openOptionsMenu(); //Opens Options Menu by clicking on an item } }); } private void init_phone_video_grid() { System.gc(); String[] proj = { MediaStore.Video.Media._ID, MediaStore.Video.Media.DISPLAY_NAME, MediaStore.Video.Media.DATA }; videocursor = managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, proj, null, null, null); count = videocursor.getCount(); GridView vGrid=(GridView) findViewById(R.id.vgrid); vGrid.setAdapter(new VideoAdapter(this)); } @Override //creates options menu with menu-items public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_gallery_share, menu); return super.onCreateOptionsMenu(menu); } @Override //what happens when a menu item is clicked public boolean onOptionsItemSelected (MenuItem item){ try{ //Facebook if (item.getItemId() == R.id.menu_facebook) { //TODO open fb new AlertDialog.Builder(this) .setTitle("No Service") .setMessage("Sorry, Facebook is not supported yet!") .setNeutralButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub }}).show(); return true; } //YouTube else if (item.getItemId() == R.id.menu_youtube) { //TODO open YouTube new AlertDialog.Builder(this) .setTitle("No Service") .setMessage("Sorry, YouTube is not supported yet!") .setNeutralButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub }}).show(); return true; } else if (item.getItemId() == R.id.menu_email) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setType("video/mp4"); i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(Environment.getExternalStorageDirectory(),"DON'T KNOW HOW TO ACCESS THE CLICKE FILENAME"))); startActivity(i); return true; } else if (item.getItemId() == R.id.menu_bluetooth) { // TODO send via bluetooth new AlertDialog.Builder(this) .setTitle("No Service") .setMessage("Sorry, Bluetooth is not supported yet!") .setNeutralButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub }}).show(); return true; } } catch(Exception e) { e.printStackTrace(); } return super.onContextItemSelected(item); } public class VideoAdapter extends BaseAdapter { private Context vContext; public VideoAdapter(Context c) { vContext = c; } public int getCount() { return count; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View convertView, ViewGroup parent) { System.gc(); TextView tv = new TextView(vContext.getApplicationContext()); String id = null; if (convertView == null) { video_column_index = videocursor.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME); videocursor.moveToPosition(position); id = videocursor.getString(video_column_index); tv.setText(id); } else tv = (TextView) convertView; return tv; } } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en