I'm frustrated as to how I can get the function to work properly. I've been researching and looking around about Intents.
At first I thought I got it right but I was wrong, some overview on what I mean. I have made an app with 6 buttons, all of which that open different applications.
- Clock, 2. Calendar, 3. Browser, 4. Messaging, 5. Phone, and 6. Contacts.
This is my onClick method for launching the contacts application.
// Contacts Launch
Button contacts_launch = (Button) findViewById(R.id.contacts_launch);
contacts_launch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent_contacts = new Intent(Intent.ACTION_MAIN);
intent_contacts.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(intent_contacts);
}
});
The onClick Intent method is the same for all my buttons, just the intent name has been changed according to the applications name, like messaging is intent_message.
When launching the application, and when I tapped the button. It prompted me with a window where I could select the application. And it ran the app every time I selected the button.
But when I select another application, it launches the contacts app? And doesn't let me choose it like before. How can I fix this? I'm pretty sure I'm using the intent function wrong.
Thanks for your time.
Please check code again, that was my modified one that didn't work which was the one with only one intent method. I added the code that I used at first where it let me choose. That's the one with the intent and category. (The one you can see now)