use of net.osmand.plus.activities.ActivityResultListener.OnActivityResultListener in project Osmand by osmandapp.
the class GpxUiHelper method addTrack.
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void addTrack(final Activity activity, final AlertDialog dialog) {
if (activity instanceof MapActivity) {
final MapActivity mapActivity = (MapActivity) activity;
ActivityResultListener listener = new ActivityResultListener(OPEN_GPX_DOCUMENT_REQUEST, new OnActivityResultListener() {
@Override
public void onResult(int resultCode, Intent resultData) {
if (resultCode == Activity.RESULT_OK) {
if (resultData != null) {
Uri uri = resultData.getData();
if (mapActivity.getImportHelper().handleGpxImport(uri, false)) {
dialog.dismiss();
}
}
}
}
});
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
// intent.addCategory(Intent.CATEGORY_OPENABLE);
// intent.setType("application/gpx+xml");
// intent.setType("text/plain");
// intent.setType("text/xml");
intent.setType("*/*");
mapActivity.registerActivityResultListener(listener);
activity.startActivityForResult(intent, OPEN_GPX_DOCUMENT_REQUEST);
}
}
Aggregations