I have an android app and I don't want to build my own maps.
I just want to send the address to Google Maps with:
Uri IntentUri = Uri.parse("geo:0,0?q=" + GETcity+ "," + GETstreet +" "+GEThouseNumber);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, IntentUri);
startActivity(mapIntent);
Do I need any permissions for that?
Is this an ok way to do it, or there a better way to build my own map?
does i need some permissions for that ?
When you launch another application to handle some task (such as taking a picture or getting the user's location), you do not need any permissions. The app you are launching is responsible for requesting the appropriate permissions.
that is ok to do it ? or its better to build my own map.. ?
This is completely up to you. If the defaults map applications provide all the functionality you want, then you probably don't need to worry about it. If you are worried that the user won't have a map app installed, or you want to provide some UI elements that the default applications don't offer, you may want to make one yourself.
Personally, I don't want to deal with the complexities that come with creating a mapping application.
No permissions needed.
If you wish to implement the Maps API, then you will need to add the specific dependencies and include the Locations permissions.
Related
I'm in the final stages of a project (my first project), but I'm stumbling in some points yet.
Like:
I want to ask the user to rate the app and also share it on facebook, but not only this, after I need also check if he/she really did this, and how many stars he/she rated the app.
I found this answer to ask the user to rate the app:
/* inside an activity */
final Uri uri = Uri.parse("market://details?id=" + getApplicationContext().getPackageName());
final Intent rateAppIntent = new Intent(Intent.ACTION_VIEW, uri);
if (getPackageManager().queryIntentActivities(rateAppIntent, 0).size() > 0)
{
startActivity(rateAppIntent);
}
else
{
/* handle your error case: the device has no way to handle market urls */
}
Seems to me a easy way, but how my app wasn't published yet, I have no way to test... And I don't know how it works (and if it works), this show a kind of native dialog? Anyone already did this way? And how I can check if a user really rated the app and how many stars the user gave programmatically? I need this answer to run a code.
And to share I can use a intent, ok, but and then, how I check if the user really shared it?
Any tip or link to any example will be very welcome.
Firstly as far as I know.. It's not possible to check if user have rated your app or not. You can google that to know the reasons. Best approach is to count launches of app by user ( ideally #5 ) then show dialog asking user rate app. You can use this tool https://github.com/delight-im/AppRater
Regarding sharing .. its similar.. Normally it should not be allowed. My favorite approach is to track user posting by injecting user data (hashed) to a link inside the post content and track clicking. You may shorten link. There are many tools to do so such as Bit.ly, use this lib to achieve that on android https://github.com/dextorer/Bitlyzer
I hope that may help,'.
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.
Background
The normal way to call for the uninstallation an app is simply by using the "ACTION_DELETE" intent :
startActivity(new Intent(Intent.ACTION_DELETE, Uri.parse("package:" +packageName)));
The problem
starting with some Android version (don't remember which) , apps can be installed for multiple users on the same device.
This means there is a new way to uninstall an app, one which will uninstall it for all users (image taken from Lollipop - Android 5.0 ) :
The question
I've searched in the documentation, but couldn't find the answer those questions:
Is there any way to perform this operation via an intent? Maybe something to add to the intent I've written above ?
Does ADB have a new command to remove an app for all users?
Is there a way to check if an app is installed for multiple users?
Is there any way to perform this operation via an intent? Maybe
something to add to the intent I've written above ?
Yes, but be careful. You can pass in Intent.EXTRA_UNINSTALL_ALL_USERS.
However, it's hidden because it:
should not be part of normal application flow
You could just pass in the constant anyway, if you feel it's necessary and disagree with Google on that one. Just for example, here are the differences between passing in false and true with that constant
final Uri packageURI = Uri.parse("package:" + "some.package.name");
final Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI);
uninstallIntent.putExtra("android.intent.extra.UNINSTALL_ALL_USERS", false or true);
startActivity(uninstallIntent);
Results
Does ADB have a new command to remove an app for all users?
No, the command remains the same.
`adb uninstall 'some.package.name'`
This will remove that app for all users. I'm unaware of a way to specify a particular user.
Is there a way to check if an app is installed for multiple users?
No, not that I'm aware of. In fact, when the Settings apps decides to place the "Uninstall for all users" option in the options menu, it's basically doing so based on whether or not there are multiple users period, not if both the current user and another user have an app installed.
Not to mention, most of the methods in UserManager that you'd need to even tell if there are multiple users on the device, like UserManager.getUserCount, require the MANAGE_USERS permission which is a system API and hidden. So, I'm not even sure why that's a public method.
Also, you can easily test all of your questions, much like I did, by creating a dummy user on your device. You don't even need to log into a Google account.
I'm trying to make an app that displays on a map the location of events, colleagues, appointments, etc. To this momento everything is fine, but now I was thinking of making it possible for the user to click the location and select a "guide me there" option, where it would open Android maps or another "pathfinding" app to the coords of that location. This because making a such a system on my app would surpass my capabilities and take a long time.
My question: is it possible to send an intent to Android maps to set travel to coords and if possible how?
AFAIK there is not an offical way to start the navigator, but
String address = google.navigation:q=yout+address+here;
Intent implicitIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(address));
startActivity(implicitIntent);
has worked for me
I use the following code:
uri = "geo:"+lat+","+lon;
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
My questions are:
1. I understand I need internet connection to use this? Is there a way to show offline Maps?
2. It opens the map with location, but without showing the point on the map. Anyway to add this with code?
The android documentation is good here: MapView
You will need an internet connection. The map data is massive and couldn't possibly be entirely cached on your phone. Don't forget to add the line in the manifest that says your application uses internet. Maybe there is a way to cache a small area if you know you will always be working with the same area, but I don't know of a way.
To show a point on the map look into "overlays" in the link I added.
Hope this helps.