Search code examples
androidversiondeviceunsatisfiedlinkerror

Android - Execute different code for different devices


my first question a few days ago didn't get any answers and I still couldn't find anything helpful on the web, so I'll give it a second try with a more generally asked question (I'm working on this for my internship and I grow rather desperate cause I don't have any (more) ideas how to solve this:

I'm writing an app, which should generally work on Android phones, but support a certain behaviour, which is currently only supported by one device (digital radio on LG Stylus 2). On said device the app works fine, but it crashes with UnsatisfiedlinkError on any other device.

I want to make the app detect the device on start and only execute the digital radio code when it is run on the right device, otherwise I want to execute different code (a web streaming radio).

I'm not necessarily asking for code, but for what would be the right approach to go about this conceptually. Any answers are much appreciated.

Thanks guys

Dave


Solution

  • You can do the following for this purpose.

    String model = Build.MODEL;
    
    if(model.equalsIgnoreCase("LG Stylus 2")
    {
        //do your task
    }