Android main project with library project - how to pass setting between projects

前端 未结 2 414
死守一世寂寞
死守一世寂寞 2021-01-21 14:12

Just started playing with Android and I\'m trying to create an app that has free and paid version. I\'m new to Java as well but I\'ve managed to create a simple working applicat

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-21 15:10

    OK I managed to solve this. In the Application Manifest, I simply set the android:label property and referenced this using the code below.

    In Manifest:

    android:label="My Free App"
    

    To reference this

    //Are we using free or pro version?
    if (this.getApplication().getApplicationInfo().loadLabel(this.getPackageManager()).toString().equals("My Free App")) 
    {
    freeVersion = true;
    } else {
    freeVersion = false;
    }
    

提交回复
热议问题