-1

I am trying to call the Maps app from within my application, fair enough I can start the Maps application but my titlebar disappears and I would like the maps to run within my app and not launch as a separate app:

MainActivity:

startActivity(new Intent(MainActivity.this, ActivityMap.class));

ActivityMap:

    actionBar = getActionBar();

    Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.google.android.apps.maps");
    startActivity(launchIntent);
user5174952
  • 127
  • 1
  • 10

2 Answers2

2

You cannot run Another App inside your app. The best you can do start a Intent via startActivityForResult() and get the result back to your app via onActivityResult once the user does some action.

For example: you can start a Camera Intent and get the image as a bitmap to your app

http://developer.android.com/training/camera/photobasics.html

pgiitu
  • 1,593
  • 1
  • 13
  • 23
1

You can of course embed a Google map view inside your own application as a MapView or as a MapFragment.

See here for the Google Maps Android API. It involves a little bit of hassle but isn't very complicated in the end. There's quite good documentation with some example code to get you started. And there's plenty of discussion already on Stackoverflow about the topic.

First of all you'll need Play Services set up for your development environment and your application project:

https://developers.google.com/android/guides/setup

You'll need to acquire a (free) API key:

https://developers.google.com/maps/documentation/android/signup

And then you can choose between

  • MapView which is just a View that you place into your Activity or Fragment

  • MapFragment which is a complete Fragment to place into your Activity (the easier option)

Markus Kauppinen
  • 2,756
  • 4
  • 16
  • 28
  • Markus, Thanks I have implemented the map however the google maps v2 does not provide navigation, all I have is a map hence I wanted to fire up the navigator app within my app, either way your answer gets an upvote – user5174952 Oct 08 '15 at 09:55