Is it possible to launch any third party application from my application on Android Auto
I couldn't find anything mentioned on this anywhere.
Note: Please note "Android Auto" (Car) words here. I am not asking for android mobile application.
Idea of android auto is completely different from what you are trying to do.
Android auto provides a platform where it has done the basic things with a good user interface making sure not to distract user much.
All that you need to do is provide services which this platform can use.
As of now you can provide Music and Messaging services which are compatible with android auto.
You can launch applications code something like
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.example.youpackage", "com.example.LauchActivity");
startActivity(intent);
And if you want get all possible application list for launch.code :
Declare you intent and add value you want pass
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
boolean isIntentSafe = activities.size() > 0;
if (isIntentSafe) {
startActivity(mapIntent);
}
And another way to start you specific application
PackageManager pm = getPackageManager();
Intent intent = pm.getLaunchIntentForPackage("com.example.package");
startActivity(intent);
Related
I am new to android. I was asked a question in an interview that all android applications has declared intent filters in their manifest file so at the time of intent resolution how the android system resolve the intent by searching all the application's manifest file or is there any implementation in android system that will record all the intent filters and from there it will search.
This is resolved with the help of intent filter defined in the menifest file. you will get good idea from this link
http://developer.android.com/guide/components/intents-filters.html
When Android OS receive a implicit Intent request it search all the package which are installed in the application. If no application is installed which can handle you implecit intent then you get ActivityNotFound Exception.
public static boolean isIntentAvailable(Context ctx, Intent intent) {
final PackageManager mgr = ctx.getPackageManager();
List<ResolveInfo> list =
mgr.queryIntentActivities(intent,
PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
You can take a look in this link.
http://books.google.co.in/books?id=lp0QAwAAQBAJ&pg=PA393&lpg=PA393&dq=how+android+os+resolve+implicit+intent&source=bl&ots=SKwCeFioNF&sig=7ao1EsrNReyeSLdvEtjDLzB_2Os&hl=en&sa=X&ei=F-j2U7bTAs--uAStxoL4CA&ved=0CDMQ6AEwAw#v=onepage&q=how%20android%20os%20resolve%20implicit%20intent&f=false
I bet Android registers all the intent filters declared on your manifest file at installation time, i dont know how exactly though. Thats how you can access the application info at run-time from the PackageManager object. Specifically, you can check out all the information regarding activities and you can even query them based on intents:
PackageManager pm = getPackageManager();
List<ResolveInfo> inf = manager.queryIntentActivities (intent, flag);
Is there any way to launch for one mobile app to launch another mobile app, e.g. via a button click?
Example: the org.apache.cordova.camera plugin allows direct access to the camera on a button click. In the same way, how can one app launch another app?
You can use this java code:
Intent LaunchIntent = this.cordova.getActivity().getPackageManager().getLaunchIntentForPackage("appPackage");
this.cordova.getActivity().startActivity(LaunchIntent);
or try any of these 2 plugins for launching apps:
https://github.com/lampaa/com.lampa.startapp
https://github.com/dmedvinsky/cordova-startapp
Try this
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("package name here");
startActivity( LaunchIntent );
If you don't know the package name of application that you want to launch then try this
PackageManager pm;
pm = getPackageManager();
// get a list of all installed apps then launch by pakagename.
packages = pm.getInstalledApplications(0);
String packagename = packages.get(position).packageName.toString()
Refer this android-package-manager
You need to find out full name of application, and then start it as activity via intent like this:
Intent myIntent = new Intent(getApplicationContext(), "full name of activity you are starting");
startActivity(myIntent);
You can even receive result from that activity check this. Hope this helps!
I'm trying to unset my app default actions with :
final PackageManager pm = getPackageManager();
pm.clearPackagePreferredActivities( getPackageName() );
It works with the primary account of the device but it throws an exception with secondary accounts:
"Neither user 1010080 nor current process has android.permission.SET_PREFERRED_APPLICATIONS."
Of course I added android.permission.SET_PREFERRED_APPLICATIONS to the manifest (but I think it is not used anymore)
I tried "to change the context" with something like:
final PackageManager pm = getApplicationContext().getPackageManager();
pm.clearPackagePreferredActivities( getPackageName() );
without success.
My App is an Home Application (for kids) that locks almost everything and I want a 'quit' button that restore user home (or the choice of home at least). May be there's another solution.
Thanks.
clearPackagePreferredActivities & addPackageToPreferred are deprecated by android since API level 8.
A modern method to set preferred activity is to start an intent, like this :
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
I have an activity that starts at boot with 9 icons in it. When user clicks on these icons, the respective apps need to be launched. Some of them are inbuilt like camera, clock, internet etc. This is on Android 3.0 (tablet). How should i achieve this?
First get list all of the available apps:
final PackageManager pm = getPackageManager();
//get a list of installed apps.
List<ApplicationInfo> packages = pm
.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
Log.d(TAG, "Installed package :" + packageInfo.packageName);
Log.d(TAG,
"Launch Activity :"
+ pm.getLaunchIntentForPackage(packageInfo.packageName));
}// the getLaunchIntentForPackage returns an intent that you can use with startActivity()
}
Link every app to a drawable(icon) and the intent
Start that intent when the icon is clicked.
I think the launching of inbuilts does not depend on Android version.
Launching camera
Launching browser
There are a lot of tips online. Search deeper.
Have you seen adw-launcher-android ?
This project is open-source and it contains classes which lists the in-built/installed applications and opens them inside this application itself.
I think this might help
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(mainIntent);
From this List you can take the required apps
I need to allow user to draw/sketch/paint something. There are already many apps(like Skitch, I will use this as an example) that accomplish this task. So I don't want to re-invent the wheel.
In Android, theoretically, we can launch other activity by intent. This is sort of like "pipe" in Unix.
The problem is, I don't know how to get the information for launching Skitch.
To integrate Skitch in my app, I need to know the Action it supports, the returning intent (if any) when it finishes.
I installed Skitch, photoshop, and lots of other touch drawing apps in my device, but this code doesn't work :
Uri data = Uri.fromFile(file);
Intent i = new Intent(Intent.ACTION_EDIT);
i.setData(data);
i.setType("image/*");
startActivityForResult(i, ACTIVITY_DRAW);
I can launch Skitch from my app in the following way: but obviously I can't get any returned result this way(code from here).
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager manager = getPackageManager();
i = manager.getLaunchIntentForPackage("com.evernote.skitch");
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
My question: Is there a standard way to find information for launching a third party app?
Is this site the only way to share/get such information?
Or if you have any suggestions for my problem, please help me.
Thank you!
As you might already know how to call another application Activity from your app ..this way Mentioned Here.
Intent intent = new Intent(Intent.ACTION_RUN);
intent.setComponent(new ComponentName("<packet name>", "<class name>"));
List list = packageManager.queryIntentActivities(intent, packageManager.COMPONENT_ENABLED_STATE_DEFAULT);
if(list.size() > 0)
{
Log.i("Log", "Have application" + list.size());
startActivity(intent);
}
else
{
Log.i("Log", "None application");
}
All your require is Mainly Two Things to call any Activity
1) Package Name of that Activity
2) Activity Class Name
These two informations only can be available if they are opensource or made free to use .. like Zxing,Google Maps Application.
There is another way to start an application activity like,
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + numberField.getText())); // set the Uri
startActivity(intent);
For this way to use need to know the correct Action for the Activity you want to call and the Correct parameter to pass with.
And again,These information only can be available if they are opensource or made free to use .. like Facebook and Gmail apps to share and post messages.
So If you are searching for anything like which can tell you what you will need to pass to call any specific comercial apps in your device, you wont find it directly.
It's an old question but perhaps it could help somebody to know that Sony's AppXplore application (free) shows the package and name of the activities of every app installed on your device, so you can eventually use them to do explicit Intents.