If you want to ask user to choose a location, you can invoke GeoPoint by Intent. And it will return the coordinate the user picks.
-invoke GeoPicker
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setClassName("com.android.lee.geopicker", "com.android.lee.geopicker.GeoPickerActivity");
/*option: the initial locaiton*/
intent.putExtra("lat", 25135022);
intent.putExtra("lon", 121516890);
startActivityForResult(intent, REQUEST);
-return coordinate
-Show GeoPicker on Android Market, if GeoPicker isn't installed.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode ==REQUEST && resultCode ==Activity.RESULT_OK){
int latE6 = data.getIntExtra("lat", 0);
int lonE6 = data.getIntExtra("lon", 0);
Log.d(TAG,String.valueOf(latE6));
Log.d(TAG,String.valueOf(lonE6));
}
}
ListresolvList=getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if(resolvList.isEmpty()){
Uri uri = Uri.parse("market://search?q=com.android.lee.geopicker");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
}
Very usefull for my App (Fontaines), thank you very much ;)
ReplyDelete