Reputation: 39
I created a button, and I want when a user clicks this button. It should run an installed app from my device (such as Maps). This is my code (button is aupeo)
aupeo.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm
.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
//Don't know how to get app's info to call it.
}
}
});
I don't know how to get app's info, call and run app.
Upvotes: 1
Views: 673
Reputation: 4425
aupeo.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setClassName("com.xxxx.your_package_name",
"com.xxxx.your_class_name");
startActivity(i);
}
});
Upvotes: 1