I want to change application configuration for the connection server where I got two options: Test, Production. This is set using a static string inside of one of my Helper classes.
Now I want to make this change from outside the application, using another icon in the system. The reason for that is that I don't want the user be able to do so (And I don't want it to be a part of my application). Only the development team that has to check the application in the field could add this icon and make this change.
So I don't want to create some kind of widget that will get installed with my application.
Is there a way to do some thing like that? If so how can this be done? Should I make a whole new application for that?
Thanks.
I have ended up using a Url Scheme
, for this task, more information can be found here:
And the code is, in my Manifest file in the main Activity I provided the following intent-filter:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" android:host="com.myhost" />
</intent-filter>
And in the activity it self I do this:
Intent intent = getIntent();
String value = null;
if (intent.getData() != null)
{
value = intent.getData().getQueryParameter("server");
}
if (value != null)
{
Log.d(TAG, "with scheme value: "+ value);
if (value.equals("my_test_server_address"))
{
Toast.makeText(this, "Server set to Test" , Toast.LENGTH_LONG).show();
}
else if (value.equals("my_production_server_address"))
{
Toast.makeText(this, "Server set to Production" , Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(this, "Server set to Address: "+ value , Toast.LENGTH_LONG).show();
}
Consts.BASE_URL = Uri.parse(value);
}
else
{
Log.d(TAG, "value was null");
}
Finally to start you application with this intent filter you need to create an HTML file, with the following code:
<a href="myapp://com.myhost?server=my_test_server_address">test</a>
<a href="myapp://com.myhost?server=my_production_server_address">production</a>