In my app I am creating a broadcast receiver which will listen for network changes. In the OnReceive it will check whether the device has just connected to WiFi and then start uploading in the background. No Activities will be shown so what do I need to do to initialize the framework without a splash Activity? I won’t need any of the page navigation parts of the framework so a stripped down initialization would be optimal.
private override void OnReceive(Context context, Intent intent)
{
bool isWifiConnected = false;
bool isMobileConnected = false;
if (intent.Action.Equals(ConnectivityManager.ConnectivityAction))
{
NetworkInfo networkInfo = (NetworkInfo)intent.GetParcelableExtra(ConnectivityManager.ExtraNetworkInfo);
if (networkInfo.IsConnected)
{
if (networkInfo.Type == (int)ConnectivityType.Wifi)
{
isWifiConnected = true;
}
if (networkInfo.Type == (int)ConnectivityType.Mobile)
{
isMobileConnected = true;
}
}
}
if (isWifiConnected)
{
StartUp(); //What do I put in this private method?
}
I have now pushed some changes to GitHub which should hopefully enable you to create your app with its BroadcastReceiver.
Using these modifications, you can now initialize the core application from any Application Component – Activity, BroadcastReceiver, Service or ContentProvider – using code like:
These changes should enable an MvvmCross application to be started in “the Intent.ActionMain” scenario, as well as in the situations:
A more lengthy explanation of these changes is http://slodge.blogspot.co.uk/2012/05/android-application-initialization-and.html