In my app i want to use galaxy s4 S-translator.So is it possible to use it? And normally can i call another app from my app.I am very new to android.So I don't know it is possible or not.So if possible plz tell me.I think by using intent with giving proper action we can do it.
Intent i;
PackageManager manager = getPackageManager();
try {
i = manager.getLaunchIntentForPackage("app package name");
if (i == null)
throw new PackageManager.NameNotFoundException();
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
} catch (PackageManager.NameNotFoundException e) {
}
thanx
Yes, by using intents.
For example:
final Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.setClassName("com.example.theotherapp", "com.example.theotherapp.MainActivity");
startActivity(intent);
This is called an explicit intent, because you're explicitly stating which component should respond to it. You can also use implicit intents, in which you specify what kind of component you expect and the OS and/or the user selects the most appropriate one.
If you can choose, implicit intents are preferred.
This might Help You.
Related
I'm looking for a way to open a browser at a specific link automatically at a give time / daily.
Maybe there is some kind of script, add-on for bowser but I still haven't find one.
Does anyone know a good solution?
I suggest you to use an AalarmManager here is an example
And then here is the code you should execute
String urlString = "your_url";
Intent intent = new
Intent(Intent.ACTION_VIEW,Uri.parse(urlString));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setPackage("com.android.chrome");
try {
context.startActivity(intent);
}
catch (ActivityNotFoundException ex) {
context.startActivity(intent);
}
Seems to me this is a combination of three things, setting the alarm, firing the intent and making sure the intent has the data to open a specific uri in the browser.
start activity from an alarm
open a uri
I am trying to open the Google Voice Search Application
Intent i;
PackageManager manager = getPackageManager();
try {
i = manager.getLaunchIntentForPackage("com.google.android.voicesearch");
if (i == null)
throw new PackageManager.NameNotFoundException();
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
} catch (PackageManager.NameNotFoundException e) {
}
This does not launch the voice search application,
however if I use com.google.android.apps.maps as the package name then the Google Maps app is opened.
I don't understand why Voice Search is not opening, even though the package name is correct.
Solution
Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
startActivity(intent);
Please see
Launch Preinstalled App from activity (Google Voice Search) Android for more information on the solution.
Thank you.
As you can read here, getLaunchIntentForPackage (String packageName)
Return a "good" intent to launch a front-door activity in a package [...]
The current implementation will look first
for a main activity in the category CATEGORY_INFO, next for a main
activity in the category CATEGORY_LAUNCHER, or return null if neither
are found.
so, in the intent, the category will already be set. If you manually change it, probably you are breaking the intent, since the category could not be the correct one that the manager found.
so, just remove the line
i.addCategory(Intent.CATEGORY_LAUNCHER);
From within my app, I'd like to start the set up new email account activity of the Email App which looks like this: http://i.stack.imgur.com/BNYnj.png
I've looked at this http://source-android.frandroid.com/packages/apps/Email/AndroidManifest.xml
and tried to start the set up email activity:
Intent intent = new Intent("com.android.email.CREATE_ACCOUNT");
startActivity(intent);
But I got an exception:
E/AndroidRuntime(517): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.email.CREATE_ACCOUNT }
Anyone please help me?
Thanks so much,
John
you could try using an explicit intent. instead of
new Intent("com.android.email.CREATE_ACCOUNT")
use
new Intent(context, com.android.email.activity.setup.AccountSetupBasics.class)
you may also want to look into the whole ACTION_ADD_ACCOUNT action string. it may do what you are looking for without having to use a SPECIFIC app. for example, when an oem installs a different email app from the stock android one. if it happens there won't be anything to handle either the explicity or implicit intent.
This works for from APIs 4.0+.
Intent intent = new Intent("com.android.email.CREATE_ACCOUNT");
intent.putExtra("FLOW_MODE", 0);
startActivity(intent);
Below works for from APIs 2.1+. Maybe also work for lower versions (not tested).
Intent intent = new Intent();
intent.setClassName("com.android.email", "com.android.email.activity.setup.AccountSetupBasics");
intent.putExtra("FLOW_MODE", 0);
startActivity(intent);
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.
What is the best way to start one android app from another app? Is it to send custom broadcast event and have broadcast receiver of other app catch this event and do a start activity on something? Thanks
Use an Intent: http://developer.android.com/guide/topics/intents/intents-filters.html
Use Context.startActivity() to just launch, or Activity.startActivityForResult() if you want to get a result when it's done.
If you are tightly coupled with the other application, you can use an explicit Intent. Otherwise, send an implicit Intent.
best way is call by intent like this
http://www.lacherstorfer.at/haris_blog/2008/03/android-howto-invoke-a-phone-c.html
Use this:
PackageManager pm = getPackageManager();
try
{
String packageName = "com.example.package";
Intent launchIntent = pm.getLaunchIntentForPackage(packageName);
startActivity(launchIntent);
}
catch (Exception e1)
{
}