I have designed a simple browser for Android using WebView
. Everything is working fine but when I open Google maps then my browser can't access the current location of the device. I don't understand what is going wrong. also in manifest I have given the permission ACCESS_FINE_LOCATION
My code is:
@SuppressLint("SetJavaScriptEnabled")
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final WebView ourBrow=(WebView)findViewById(R.id.wvBrowser);
Button bgo=(Button)findViewById(R.id.button3);
Button res=(Button)findViewById(R.id.button4);
Button gfo=(Button)findViewById(R.id.button2);
ourBrow.getSettings().setJavaScriptEnabled(true);
try {
ourBrow.loadUrl("https://www.google.co.in/maps/dir///@20.3464436,85.8127819,15z");
} catch(Exception e) {
e.printStackTrace();
}
bgo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(ourBrow.canGoBack())
ourBrow.goBack();
}
});
gfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(ourBrow.canGoForward())
ourBrow.goForward();
}
});
res.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
ourBrow.loadUrl("https://www.google.co.in/maps/dir///@20.3464436,85.8127819,15z");
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}