Launch another App within an App for android - android

I am new to Android. Say, I open an app and I would like to open another App after clicking a button. How can I accomplish this task? Would appreciate if you can provide me some tutorial on this.

Intent intent = new Intent();
intent.setClassName("**package.name**", "**package.name.LauncherActivityName**");
startActivityForResult(intent,REQUEST_CODE);
You need to know the package and class names of the activity to call

Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager manager = getPackageManager();
i = manager.getLaunchIntentForPackage("app package name");
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);

Use this code:
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.example.package");
startActivity(launchIntent);
The app you want to launch must be on the device.

Intent appIntent = getPackageManager().getLaunchIntentForPackage("your app package name ");
startActivity(appIntent );

If the other application is a pre-packaged application mean, this tutorial may help you.
If the other application is going to be your application, then you need to learn Implicit Intent tutorials.

Also include the activity of the other application which you are planning to call in the Manifest file of the calling package also.

Related

How to launch a mobile app from another app?

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!

How to link 5 apps from one app. New to android

I have 5 android apps and im trying to make a front page that has 5 buttons that connects to each one. How do I go about this? i tried to create a onclick method in layout but it didnt work.
you can use the package name of App to open them on button click as :
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);
Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setData(Uri.parse("https://play.google.com/store/apps/details?id=your Package name"));
startActivity(i);
Declare it in your Activity.
Let me know if it helps you.

How do we find the information for launching other app?

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.

Start android application from code

I need simple start an application from my code, like Skype, or other one.
I read some thread, on the internet, but I haven't solution.
I tried this methode:
Intent startApp = new Intent("com.android.gesture.builder");
startActivity(startApp);
I wrote this in try/catch blokk, and the LogCat told me: ApplicationNotFound exception handled by Intent. I read the "Hello" tutorial on the Android Developers site, but it's too comlicated, to my solution...
I can't register this application starting activity to my manifest file.
I think I need to implement a new class, that extends from Activity, and implement, the code above, and try again?
Please help me, how can I start other application from my main activity easy...
You were nearly there!:
You just need to supply the package and class of the app you want.
// Try
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setComponent(new ComponentName("com.htc.Camera", "com.htc.Camera.Camera"));
startActivity(intent);
// catch not found (only works on HTC phones)
ComponentName
I also just saw you can do it a second way:
PackageManager packageManager = getPackageManager();
startActivity(packageManager.getLaunchIntentForPackage("com.skype.android"));
See: SOQ Ref

Is there a way to direct the user to the market for another app?

I want to direct the user from one app the user is currently running, to the market, to download another app.
The link to the market is: market://search?q=pname:your.package.name
use this in your code:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.android.example"));
startActivity(intent);
from: http://developer.android.com/guide/publishing/publishing.html#marketintent
Yes. Try this:
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://market.android.com/details?id=com.hg.cyberlords"));
c.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
c.startActivity(intent);
This will open the market app with "Cyberlords" app.

Categories

Resources