I am developing an android app. My app needs to show a pin on Google Maps at the time user clicks on the ListView item but I don't want to put the Google Maps into my application - instead, I want to launch it using an Intent. Is this possible?
Following is my DisplayActivity.java file. I want to call Google maps app(if app not installed it should notify user) when user clicks on any item from nameAddressList which is assigned to ListView through adapter.
DisplayActivity:
enter code herepublic class DisplayActivity extends Activity {
ListView listView;
private String tag_name;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display);
listView = (ListView) findViewById(R.id.list);
Intent intent = getIntent();
if(intent!= null)
{
//int imageId = intent.getIntExtra("DashboardImage",R.drawable.apartments);
tag_name = intent.getStringExtra("DashItemName");
}
List<NameAddress> nameAddressList = null;
try {
XMLPullParserHandler parser = new XMLPullParserHandler(tag_name);
nameAddressList = parser.parse(getAssets().open("data.xml"));
ArrayAdapter<NameAddress> adapter =
new ArrayAdapter<NameAddress>(this,R.layout.list_item, nameAddressList);
listView.setAdapter(adapter);
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.display, menu);
return true;
}
}