Hi,
in my code I am trying to call the last clicked item within an
intent.
Inside an onClick event, the Uri gets tagged to keep track of the item
that was clicked, but I don't know how I can call this uri now from
within the intent.
What I mean is: here I tag the item...
vGrid.setOnItemClickListener(new OnItemClickListener() {
@Override // click on item and open options menu
public void onItemClick(AdapterView<?> parent,
View v, int
position, long id) {
//get uri of selected/clicked video
String uri = (String) v.getTag();
String [] proj={MediaStore.Video.Media.DATA};
videocursor =
managedQuery( MediaStore.Video.Media.EXTERNAL_CONTENT_URI, proj,
null,null,null);
videocursor.moveToPosition((int)
vGrid.getSelectedItemId());
// print the filename
Toast.makeText(ShareGalleryView.this, "You just
selected "
+uri, Toast.LENGTH_SHORT).show();
openOptionsMenu(); //Opens Options Menu by
clicking a video
}
});
and inside an menu I would like to call the item that was clicked and
attach it to the new intent: i.putExtra(Intent.EXTRA_STREAM,
Uri.fromFile(new File(""))); //HOW TO CALL THE CLICKED ITEM??
@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(""))); //HOW
TO CALL THE CLICKED ITEM??
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);
}
Any help is welcome, I would really appreciate if someone could give
me a hand here.
Thank you.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en