In my webview there is no long click and show up a context menu where i can save link as save image and so on.
Here is my work so far:
registerForContextMenu(mWebView);
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Menu");
menu.add(0, v.getId(), 0, "Save As... Or save image");
}
@Override
public boolean onContextItemSelected(MenuItem item) {
if(item.getTitle()=="Action 1"){function1(item.getItemId());}
else {return false;}
return true;
}
public void function1(int id){
// HOW DO I SAVE??
}
SO i cannot really find a working code how to save the selected online image…!
Can you guys help me out?
And have i done the context menu wrong??
Thank you!
When you register for a context menu you need to specify which element in your view you’re registering your context view for. mWebView could be referring to the entire view in general and not solely the links on the page. Have you checked this?
For example consider this:
In this example, i am registering the GridView part of my entire view to the context menu, so only when the items in the GridView are pressed for long enough, the context menu appears.