Opening fm radio from an Android application

I am developing an application in which I need to open the FM radio installed in the device. it is only โ€œFM radioโ€ and not โ€œInternet FM radioโ€.

I know how to open another application using intention

Intent i = new Intent(Intent.ACTION_MAIN); PackageManager manager = getPackageManager(); i = manager.getLaunchIntentForPackage("com.sec.android.app.fm"); i.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(i); 

But I need the package name of the fm radio application in each device, is there a way that I can query the package name and open the fm radio application.

At the moment I use the galaxy samsung S..fm the name of the radio packet in this device

 com.sec.android.app.fm 

Will this package name be the same for all Android devices.

Anyone please help ..

+4
source share
1 answer

CyanogenMod uses com.android.fm , for example. I'm not sure about other vendor-specific applications, but I would say that their package names can be very different.

Currently, two, but not necessarily mutually exclusive options come to mind:

  • Using a heuristic approach to collect likely candidates for the name of the radio package *
  • User requirement to select a radio application from the list of all installed packages

If your application has permissions to access the Internet, you can also collect package names discovered using any method to compile a static list of package names to be included in your next release, hoping to free new users from having to manually select their radio applications .

*) Using PackageManager.getInstalledApplications(...) and scanning the returned List for the entries ".fm." , ".fm" , etc., you can get a list of possible candidates.

+4
source

Source: https://habr.com/ru/post/1398766/


All Articles