Search code examples
android

Display other builtin app on the top of current app (Display overlay)


I'm developing an app, it will interact with user. and i found an app named "Assistant" on Google Play. When i say " google map" it loaded google map (built-in app)and display on the top of current app(Assistant), similary i say "facebook.com" it loaded webpage "facebook.com" and i still interact with "Assistant" it so great!

Assistant on GooglePlay:

https://play.google.com/store/apps/details?id=com.speaktoit.assistant&feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5zcGVha3RvaXQuYXNzaXN0YW50Il0.

My questions :

  1. How to display that?

  2. Any sample code or Tutorial?

I found this link, it's similary with my question:

Overlay an activity on another activity OR overlay a view over another

How would I display one view as an overlay of another?

See my picture to detail. http://imgur.com/NiJJoLk


Solution

  • first I think it is embedded rather than an activity in another activity. here is a tutorial in embedding google maps in an app. It is pretty straight forward. You can put just about anything inside of an activity. Also using google API's can be very helpful. In regards to using voice commands or getting a result from spoken commands I would check this out. That will explain how to implement a voice command which you can then start an activity made for that specific command. Once you have an idea of where to start as you hit speedbumps let the community know and a more direct question on coding can be answered. I hope this helps put you in the right direction :)

    COMMENT QUESTION:

    thank Mark.Could you give me some detail, how to embedded activity to other?Your link not mention about this. Thank

    Well first you must understand android is based on view and activities. I find it best to have an activity for each page. So for example if a user press button A then you want to start a new activity. The next activity can be setup from the beginning to handle the one task you want it to. so say Button A is the map view page. You would follow the guide to setup the page with the mapview. Now to call a new activity say on the press of the button the you would the following as a guide:

    Intent back2MainScreen = new Intent(getApplicationContext(), MainScreen.class);
    back2MainScreen.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(back2MainScreen);
    

    now in the above code MainScreen.class is your java activity that would be in your source. the flag is just standard and should be included. then the startActivity starts the next activity. you pass the Intent to it. You can add bundles to the Itent and this will allow you to transfer data through the activities. Say the user inputs a zipcode and you want to zoom in on that area on the map, well you are gonna want to pass the zipcode to the next activity so the google map can display the right area.

    this explains going from one activity to the next. Android is similar to a whole bunch of pages put together. you can change a page in the activity but I like to make use of the back button. So since I do not have many pages (less than 15) its best for me to have different pages for different tasks. Also you can have a number of different views and have them INVISIBLE or GONE until the user clicks the button. I would not recommend that especially if you are just starting with android. It can make things confusing for you.