If you think the Android project Go2-Rennes listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*******************************************************************************
* Copyright (c) 2011 Michel DAVID mimah35-at-gmail.com
* //www.java2s.com
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/package fr.gotorennes;
import android.app.Activity;
import android.app.AlertDialog;
import android.appwidget.AppWidgetManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import fr.gotorennes.util.BackgroundTask;
publicabstractclass AbstractConfigurationActivity extends Activity {
protected GoToRennes goToRennes;
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
BackgroundTask<Boolean> backgroundInit = new BackgroundTask<Boolean>() {
@Override
protected Boolean execute() {
try {
goToRennes = GoToRennes.getInstance(AbstractConfigurationActivity.this, null);
} catch (Exception ex) {
return false;
}
return true;
}
@Override
protectedvoid callback(Boolean result) {
if (result == null || !result) {
showError(getString(R.string.erreurInitialisation), true);
} else {
init();
goToRennes.track(getTrackingName());
}
}
};
backgroundInit.start(this);
}
protectedabstractvoid init();
protectedabstract String getTrackingName();
@Override
protectedvoid onDestroy() {
super.onDestroy();
if (goToRennes != null)
goToRennes.stop();
}
protectedint getWidgetId() {
Intent intent = getIntent();
Bundle extras = intent.getExtras();
int appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
if (extras != null) {
appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
}
if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
finish();
}
return appWidgetId;
}
protectedvoid showError(String message) {
showError(message, false);
}
protectedvoid showError(String message, finalboolean finish) {
AlertDialog.Builder build = new AlertDialog.Builder(this);
build.setMessage(message);
build.setPositiveButton("Ok", new android.content.DialogInterface.OnClickListener() {
@Override
publicvoid onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (finish)
finish();
}
});
build.create().show();
}
}