I want to create an Intent in my Android app that launches a map application with a specified address in response to the user clicking on the button. It is straightforward enough to do this with Google Maps, as is explained here.
However, I was wondering what the correct way to do this would be in order to launch any maps application (i.e., not necessarily Google Maps). This way, if the user prefers a different maps application, it would open in their app of choice instead.
For example, to launch the user's preferred calendar application, one sends an Intent to com.android.calendar, and it opens whichever calendar application is the default, not necessarily Google Calendar.
Use a geo: URI, as stated here. Disappointingly, this does not provide a mechanism for launching directly into turn-by-turn navigation.
Related
I am working on an android app and when a user clicks on a link and/or file, I want to give them the choice of choosing which app they want to use to open that link and/or file. At the moment it works the way it was intended to, but I am having trouble trying to let the user select a checkbox which lets them choose the default app to open that file with so they won't have to keep selecting it each time. I was thinking of having a checkbox in the dialog and then committing the value of it to the Shared prefs along with the app choice. After that, each time they click that file, the default app will be opened. In essence I am trying to get a dialog like this one,
But I keep getting this one,
Here is the code:
Intent intent = new Intent(Intent.ACTION_VIEW).setDataAndType(uri, mimeChoice);
startActivity(Intent.createChooser(intent,getActivity().getString(R.string.open_with_title)));
like tambykojak point out, the "The Android OS will take care of this depending on the Intent you've constructed" and thereĀ“s no option for default app. But you will construct your own custom dialog by gettin the apps installed determined by the package:
for example:
Facebook: "com.facebook.katana"; Whatsapp: "com.whatsapp"; Twitter: "com.twitter.android"; Google Playstore: "com.android.vending"; Chrome: "com.android.chrome" etc...
And saving the "default" option in preferences.
More info:
How to force Share Intent to open a specific app?
How to filter specific apps for ACTION_SEND intent (and set a different text for each app)
Recently my employer asked me to build an app which is to be deployed on the field (for field workers) having features such as:
-when the phone starts the app should automatically fire up and no one is able to make use of other phone's features such as calling, texting etc.
Also, the app should be as such that it cannot be uninstalled.
Imagine a complete restricted access to phone's features except my app; a total lock down situation?
So, how really can I go about this? Will I need to build a whole new custom ROM loaded with my app? Or will I have to make use of app's "permissions" to lock down the system? Which is better?
Where should I start?
My app has to make use of SQLite, GPS, Wifi/2G/3G network and camera access.
Any advice would be appreciated.
Thanks
U can create an application which will be listening for Activity starting event. When u catch this event u can start your own activity. This activity will suppliant uninstall activity. To catch event - use logcat reading
or
If your are going to launch your own android phone, put your application in the android source, like the other native applications like Myfiles, Gallery. and
modify the source, so that in Settings --> Manage Applications there
is no entry for your application.
First of all I should say such a horrible plan
you can not prevent system to uninstall your application. According to your client's requirement you can only do one thing. That is to launch the application when the phone is started by using BOOT_COMPLETED intent filter
I'm trying to obtain a share dialog similar to the one below for sharing some plain text with a preselected list of apps (email, Facebook, Twitter, Google+). The problem is that if I launch an intent to share text, the dialog has too many apps.
1) Can I explicitly choose the apps shown in the dialog?
2) If not, I can make a custom dialog. If so, can I specifically choose an app to launch and provide it with my intent? for each dialog option, I'd launch a specific app. First item - email, second item - facebook etc.
1) Can I explicitly choose the apps shown in the dialog?
You cannot modify this list that the OS creates with the app chooser. (I'm guessing that all of these apps accept the very common data type "text/plain".)
2) If not, I can make a custom dialog. If so, can I specifically choose an app to launch and provide it with my intent? for each dialog option, I'd launch a specific app. First item - email, second item - facebook etc.
As far as building your own custom list, you need to consider a few points:
You could create Intents that explicitly open the GMail and Facebook apps, but some users don't use these particular apps. Instead you should display apps that accept specific data types (or MIME types).
Email apps have a specific MIME type: "message/rfc822", but some don't use it. You might be safer using "text/plain".
I am unaware of any specific Facebook MIME type, you will have to use "text/plain" anyways. Alternatively, you could use the PackageManager to search every installed appfor the string "facebook", however a third party Facebook app might not have this string in its package name....
If you are going to use the "text/plain" data type then you will end up with the list that the OS already automatically created for you...
What you want to do is not impossible, but it is harder than it sounds. In the end you accidentally might exclude the user's favorite app from your customized list...
(Android has an insightful blog on this subject: Sharing with Intents.)
This is an Android noob question.
I am trying to start an activity of another apk through my own application. Now I know I can launch any other application and invoke its main activity. In many cases I'm also able to start subactivities, for example display it's settings dialogue.
However with some applications, for example Facebook or Endomondo I would get a FC everytime I try to launch some specific activity of their application.
Now I suspect that this is a permission issue and that the Facebook or Endomondo devs just don't want other applications to get access to their activities. But do I have to find out which activities I can use and which ones I can't use by trial and error every single time?
Plus: Is there any way around this dilemma? Maybe on a rooted device?
Cheers for any pointers.
As you already said you can only use activities of other apps which are designed to be used by others applications. Normally the developer of the other app define a set of intents and actions their app will be able to understand and process.
Using any other app's activity is by default not possible, this is by design of Android as every app runs in it own sandboxed process (there are some exceptions where apps can share a process).
So to use another app's activities you must know the intents it listen on. Normally this can be found in the applications website or documentation or on OpenIntents a dictionary for intents.
I would like to extend the Android platform's default Gmail/Email applications either by plugging into their ContentProvider or by using intent filters. Essentially, I want to be able to scan incoming emails for special rules that will trigger events in my Android application. If scanning emails automatically isn't possible, then I would at least like to add a menu item to the email viewer screen that would allow the user to flag the email content as needing to be scanned.
Does the Gmail/Email applications allow you to extend them in this way?
For future reference, besides finding sample code or reading documentation provided by the author of an application, is there a standard way of finding out what intents are available for my application to use? Like a tool maybe?
Thanks,
Marc
Does the Gmail/Email applications allow you to extend them in this way?
Gmail is closed source, and so it is difficult to know what it does or does not support.
The Email application is not part of the public SDK, so trying to rely upon any ContentProvider it may have (and I don't know that it has one) would be a mistake, as your application is liable to break with subsequent Android updates.
I would at least like to add a menu item to the email viewer screen that would allow the user to flag the email content as needing to be scanned.
The only way to do that assumes Gmail/Email uses Menu#addIntentOptions(), and via Google Code Search, this does not appear to be the case.
You might consider contacting the developers of K9 to see if you could hook into their Android email application.
is there a standard way of finding out what intents are available for my application to use? Like a tool maybe?
Not really. Intent actions are just strings.