I made a GUI using Android studio that contains 4 buttons and I want to open separate apps which already installed in my phone (Facebook, Twitter...) as they click on. I'm a novice in Android St. and can anyone help with my problem?
Asked
Active
Viewed 328 times
-1
-
1USE INTENT FOR THAT – Vishal Patoliya ツ Sep 02 '16 at 10:42
-
2Check here : http://stackoverflow.com/questions/2780102/open-another-application-from-your-own-intent/ – RamithDR Sep 02 '16 at 10:45
2 Answers
2
if (v.getId() == R.id.ImageButton01) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
// Toast.makeText(this, "Application Name", Toast.LENGTH_LONG).show();
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setClassName("com.xxx.your_package_name",
"com.xxx.your_class_name");
startActivity(i);
}

h_patel
- 744
- 5
- 16
0
Intent intent = new Intent();
ComponentName comp = new ComponentName("packagename", "packagename.Activity");
intent.setComponent(comp);
startActivity(intent);
Put this code in your onClick()

Pankaj Jadhav
- 81
- 7
-
-
You will have to do like this `final PackageManager pm = getPackageManager(); //list of installed apps. List
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)); }` – Pankaj Jadhav Sep 02 '16 at 11:01