I want to show navigation direction while clicking the info window.
I tried some code, it shows the Preview button, but it does not show the navigation button.
I got it like in the picture below:
But, I want it like this:
Here my code:
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?" +
"saddr="+ gps.latitude + "," + gps.longitude + "&daddr=" + marker.getPosition().latitude + "," +
marker.getPosition().longitude+ "&sensor=false&units=metric&mode=driving"));
intent.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity");
startActivity(intent);
You can follow this documentation on how to launch Google Maps navigation with turn-by-turn directions to the address or coordinate specified.
Here is a sample Intent which requests turn-by-turn navigation to Taronga Zoo, in Sydney Australia:
Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);
Check these related SO threads:
Is there an API for Google Maps navigation in Android?
Android Google Maps API v2 start navigation
Related
We can ask the user to protect our app, by using (e.g. Huawei phones):
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"));
startActivity(intent);
Is there a way of knowing if the app got protected or not? I'm trying to avoid asking the user to protect the app e.g. every time the app is created.
For other intents, I can use:
List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(
new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, Uri.parse("package:" + getPackageName()))
,
PackageManager.MATCH_DEFAULT_ONLY);
System.out.println("MY_intent_TEST_1(looks always true): "+( list.size() > 0 ) );
PowerManager pwm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
System.out.println("MY_intent_TEST_2(true when whitelisted): "+ pwm.isIgnoringBatteryOptimizations(context.getPackageName()) );
P.S. I'm learning from: "Protected Apps" setting on Huawei phones, and how to handle it
Because related interfaces are not exposed, currently you cannot get to know whether the app got protected or not.
I am creating a Google Maps app. In my app I am searching for nearby ATMs by using Places type "ATM". It all works perfectly, but I have to find specific nearby ATMs such as Axis bank ATMs. So how do I do this?
I have implemented the same in my app . Use the following function for the same:
private void showNearbyAtms(){
Uri mapIntentUri = Uri.parse("geo:0,0?q= Axis atm");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, mapIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
if (getActivity() != null && mapIntent.resolveActivity(getActivity().getPackageManager()) != null) {
startActivity(mapIntent);
}
}
hello i have an app of POS ( point of sale )
i wanted to make it send printing data to be printed through bluetooth printer
i found this solution
https://play.google.com/store/apps/details?id=com.fidelier.posprinterdriver
its a driver for my printer
they say
+### Print from your Android App (interactive user action)
+
+Create your ESC data using the helpers Create an Android Intent using Add your ESC data as a “Data” extra Start the intent.
+You can be printing in minutes with just a couple lines of code. It's as simple as creating your intent, adding your ESC formatted string and start the (service) intent.
+
+Example:
+
+```java
+
+String dataToPrint="$big$This is a printer test$intro$posprinterdriver.com$intro$$intro$$cut$$intro$";
+
+Intent intentPrint = new Intent();
+
+intentPrint.setAction(Intent.ACTION_SEND);
+intentPrint.putExtra(Intent.EXTRA_TEXT, dataToPrint);
+intentPrint.setType("text/plain");
+
+this.startActivity(intentPrint);
+
+```
can any body tell me how can i do that ???
where should i put these codes ? ?
Lets say you have your activity with a button link to this method :
public void click(View v){
Intent intentPrint = new Intent();
intentPrint.setAction(Intent.ACTION_SEND);
intentPrint.putExtra(Intent.EXTRA_TEXT, "Just some dummy text to print");
intentPrint.setType("text/plain");
this.startActivity(intentPrint);
}
By clicking on this button, the intent will be launched, this will probably open a list of application that can handle this kind of intent (ACTION_SEND), choose the correct one and this should do it.
I want to query all activitys that can play a music file.
I have tried to get all music players like this:
Intent resolve_intent = new Intent();
resolve_intent.setAction(android.content.Intent.ACTION_VIEW);
resolve_intent.setType("audio/*");
packages = getPackageManager().queryIntentActivities(resolve_intent, 0);
if (packages == null || packages.size() <= 0)
{
//none found
}
but i everytime get an empty (or null) list...
if i do this for type = "image/* or "video/*"
i get all applications that can handle this type.
only for "audio/*" i get no players installed, even if i know that there is one...
so what am i doing wrong?
Fond it myself:
i forgot to set the Data, and i didn't know android uses the data too
to resolve the matching intents...
working code:
Intent resolve_intent = new Intent();
resolve_intent.setAction(android.content.Intent.ACTION_VIEW);
resolve_intent.setDataAndType(Uri.fromFile(new File("/some/path/to/a/file")), "audio/*");
List<ResolveInfo> packages = context.getPackageManager().queryIntentActivities(resolve_intent, 0);
I've created an address book app, and am trying to add some features to it. What I'm trying to do right now is add the ability to longclick a phone number, and then either call/text/mms the number. This all works fine with phones, but I was wondering how to do this on tablets, since they will not have that same ability. The device I'm debugging on is a tablet, and I use HeyWire for texting. I know there are apps out there for calling via WiFi as well. Here's what I have so far for the texting section of my switch statement:
case 1: //SMS
if(CanCallAndText)
{
CustomSMSDialog SendSMSDialog = new CustomSMSDialog(BrowseListActivity.this, ParsedPhoneNum);
SendSMSDialog.setTitle("Sending text to " + PhoneNum);
SendSMSDialog.setCancelable(false);
SendSMSDialog.show();
}
else
{
try
{
Intent WiFiSMS = new Intent(Intent.ACTION_VIEW);
WiFiSMS.setData(Uri.parse("sms:" + PhoneNum));
WiFiSMS.setType("vnd.android-dir/mms-sms");
startActivityForResult(Intent.createChooser(WiFiSMS, ""), 0);
}//endtry
catch(Exception e)
{
Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
}//endcatch
}//endelse
break;
I don't know if I'm doing the create chooser incorrectly or not, but it simply tells me that no apps can handle it. Thank you!
EDIT: Ooh, spotted a slight error that I should fix tomorrow. The URI should include ParsedPhoneNum, instead of PhoneNum. Anything other than a number, like a -, would be included in PhoneNum.