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);
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
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)
Related
I am working on a project to integrate the Google Assistant with an existing Android app. The requirements are simple. Assuming my app is named TestApp and I want it to just Create a meeting, I want to be able to say, "Hey Google, Create a meeting on TestApp".
The closest API I found that does what I need is the Voice Interactions. This is very similar to what I need done but it only allows preset voice triggers such as "call this person..." or "set alarm at...", but cannot do "create a task or something else..." like in my example. According to this link, custom voice actions aren't allowed.
So my question is, is it possible to directly interact with my app and have it do a very simple task?
Short Answer: No, not directly. But your Action can be made to prompt the user for permission to "deep-link" into an Android activity. To do that you need first to associate the Action and the Activity in the console. Sample code is here
https://actions-on-google.github.io/actions-on-google-nodejs/classes/conversation_helper.deeplink.html
Longer Answer: Before there were Actions on Google there were Google Now Actions. (Yeah I know it's confusing). With Google Now Actions the Google App on a phone can be made to launch an Android activity with an intent which carries search terms in the bundle of "string extras". Then your user would say something like
"OK, Google search for the meeting creator on TestApp". Then you would get the text "the meeting creator" as a query string extra in a specially crafted search intent which launches TestApp into its meeting-creating activity. Details are here:
https://www.seroundtable.com/google-now-actions-19436.html
Unlike Actions on Google, Google Now Actions forces your user to pose his request as a search.
I'm trying to develop an interactive "allspeech-based" application and I have found some troubles.
I would be able to do every task of my app without the touch input, only the voice one.
So, my idea was to use Google Assitant to open my app, and then execute tasks with Activities "allspeech-based". My only problem is open my app with a custom phrase like "Hello myApp".
I've noticed that Google only permit to define in Manifest in which developer can set predefined method like SEARCH_ACTION (I have to say "Serch cats in myAPP..."), ... and not custom action!
Then I had an idea: to resolve this I can define a new routine in my Google Assistant where Command is "Hello myApp" and action is "Open myApp", and it works!
But I don't want to force my users to add a new tourine in their Assistant, I want to do it from my app automatically at the first opening of my app (throught an Intent and a startActivity or something similar idk).
My question is: How can I do? Which Intent I have to invoke? With which extras? Is it possible?
Please answer, thank you.
There's no such intent which can directly create a new routine.
in my android application I want the user will be able to choose some location and to get this location back to the application code.
something like startActivityForResults.
Does it's possible?
I know that it is possible with all the google service sdk and all of this,
but I want to use only the content intent, like described here:
https://developers.google.com/maps/documentation/android-api/intents#overview
and here (in the maps section):
http://developer.android.com/guide/components/intents-common.html
thanks a lot.
There is no requirement for an Android device to have an app that does what you want. There is no standard Intent structure for this, either.
I have an app containing a button which should present the user with directions to a local business. I wish to supply the directions using Google Maps with the inclusion of step-by-step road directions from the user's current location.
I wish for the native Google Maps app to handle the directions, but when I tried a href of https://maps.google.com/maps?q=..., Google Maps in opening the user's web browser, rather than in their Google Maps app.
This web-based map is not providing the step-by-step directions that I desire - it only provides an overhead view from point A to point B.
I have also tried
businesname
and
businessname
These hrefs do launch the native Google Maps app, but step-by-step direction are not shown.
In summary: how can I display a Google Map view to give step-by-step directions (preferably using the native app).
What you are looking for is called an intent. It is a command that passes some informations to an other app an can launch it.
What I would do is adding a method in your code that is called when the user touches the button. This method would be something like:
//Pass the link to the itinerary you want
void launchGMaps(String link) {
//Pass the link and the instruction to show something to an Intent
Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(link));
//Give the name of the app to start and the activity to start in this app.
myIntent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
//Gooooooooooo !
startActivity(myIntent);
}
I hope it helped.
F
If you DO NOT have inAppBrowser plugin loaded, you can do:
window.open("http://maps.google.com/maps?saddr=some+address&daddr=another+Address");
it will open a new browser window with the directions (but not the native app)
Or you can use the previous answer frouil, but to do so you must do the following.
In your main Java file, add, before the super.loadUrl call:
appView.addJavascriptInterface(this, "YouActivityName");
Then from your javascript, you use following method:
window.YouActivityName.launchGMaps("http://maps.google.com/maps?saddr=some+address&daddr=another+Address");
If you omit the saddr part android will try to use your current location and start address
You don't need any plugin.
Just Use this for any version of phonegap but don't use href in phonegap 3x.
Use window.open();
For Navigation -
window.open("google.navigation:q=23.3728831,85.3372199&mode=d" , '_system');
For Search -
window.open("geo:0,0?q=pizza" , '_system');
Read Here - https://developers.google.com/maps/documentation/android/intents
I've done some research (Stack Overflow and on the web) and see that there are some other questions about Google Goggles and the possibility of using it with Android; via an Intent. I realize it is not officially supported and that we are all still waiting for Google to open up the API or provide us the functionality to easily use it in our apps.
That said - I would still like an answer / some clarification on the following, if anyone can help?
Referencing this question: zxing intent "google goggles" doesn't recognize barcodes
It is answered that Google Goggles does decode barcodes, which indeed it does... so in my app I am calling to the latest version of the Google Goggles app via the IntentIntegrator:
https://code.google.com/p/zxing/wiki/ScanningViaIntent https://code.google.com/p/zxing/source/browse/trunk/android-integration/src/com/google/zxing/integration/android/IntentIntegrator.java
This call via the IntentIntegrator successfully opens Google Goggles in scan mode (of sorts), however there is no 'Capture' button displayed on the UI, it is hidden / unavailable ... so it is not possible to take a shot / capture any image, to see if the callback with result to my app works.
So my thoughts are:
This just isn't supported and the button is disabled because of the way I called to open Google Goggles?
I've done something wrong in the way that I am making the call?
The latest version of Google Goggles disables this functionality that used to be available in previous versions?
Other?
Code sample of how I'm making the call to open Google Goggles below. Also another way to do the same thing is included, but commented out for reference.
// Try and open Google Goggles for scanning
try{
IntentIntegrator integrator = new IntentIntegrator(getSupportActivity());
integrator.initiateScan(IntentIntegrator.TARGET_ALL_KNOWN);
//Intent intent = new Intent("com.google.zxing.client.android.SCAN");
//intent.setPackage("com.google.android.apps.unveil");
//startActivity(intent);
}catch(Exception e){
Log.e(ScanFragment.class.getName(), "onViewCreated > Error creating scan Intent to Google Goggles: " + e.getMessage());
}
//>
Any help on finding out more on this would be greatly appreciated; thanks.
// WildStyle
Yes, I am actually not sure Goggles supports this Intent anymore. It is not in the list of apps that will be targeted by default. So I don't think you are opening Goggles if you are using IntentIntegrator; you are opening one of the Barcode Scanner apps. They don't have a capture button, you just bring the barcode into view.
If it's really opening Goggles, maybe it was previously set as the default for this Intent and that is taking precedence. Try clearing application handler associations in Settings.