Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a frequency for the fm radio in android?

Tags:

java

android

In my android app I am using this intent to start fm radio

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);

Is it possible to set a manual frequency and open the fm radio? Thanks

like image 713
Amila Iddamalgoda Avatar asked Mar 24 '14 05:03

Amila Iddamalgoda


2 Answers

There is currently no native Android API for playing FM radio.

You need to use 3rd party apps to play FM radio, and each phone vendor / app vendor has it's own API.

You best option is to contact them directly and ask for the relevant API to suit your needs.

Hope this helped!

like image 178
gilonm Avatar answered Nov 09 '22 12:11

gilonm


I've decompiled FM Radio app, and I saw this code:

    void sendFMStatusBroadcast(float p1, String p2) {
        Intent localIntent1 = new Intent("com.android.fm.player_lock.status.channel");
        if(FMRadioProperties.getRegion() == 0x65) {
            localString2 = String.format("%.2f", Float.valueOf(p1));
            localIntent3.putExtra("freq", "%.2f");
        } else {
            localIntent1.putExtra("freq", p1 + "");
        }
        localIntent1.putExtra("name", p2);
        sendBroadcast(localIntent1);
    }

You should also decompile FM Radio app and search for intent in the Main Activity, and work with that code to get through your problem.

like image 44
The Badak Avatar answered Nov 09 '22 12:11

The Badak