0

I am making a app which when triggered by Bluetooth text sent by an Arduino, opens the voice to text feature in the SDK and process what the user said to do actions. The problem for now it that i cant find a way to open the app the user said. For eg, Open whatsapp. How can i open whatsapp or any other app the user says. Please help me fast. I have googled up but only found to luanch apps using the package name. - DevanCoder

1 Answers1

0

Android manages application basing on package name. Hence, you must use it to launch an application. Please try below steps:

  1. When a user says: "Open Whatsapp", from your application, search all installed applications (get both application name and package name). Something like this:

    Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    List<ResolveInfo> pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);
    
  2. From the list of application names, you can pick the best match, then open the application base on its package name

Sunil Sunny
  • 3,949
  • 4
  • 23
  • 53
Cao Minh Vu
  • 1,900
  • 1
  • 16
  • 21