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
* /*fromwww.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.appwidget.AppWidgetManager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
publicclass ClockActivity extends Activity {
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.clock_popup);
final SharedPreferences prefs = getSharedPreferences("fr.gotorennes.BikeWidget", 0);
finalint appWidgetId = getIntent().getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, 0);
Button reinit = (Button) findViewById(R.id.buttonInit);
reinit.setOnClickListener(new View.OnClickListener() {
@Override
publicvoid onClick(View v) {
prefs.edit().putInt("timeLeft" + appWidgetId, 30).commit();
resetWidgetAlarm(appWidgetId);
finish();
}
});
Button stop = (Button) findViewById(R.id.buttonStop);
stop.setOnClickListener(new View.OnClickListener() {
@Override
publicvoid onClick(View v) {
prefs.edit().putInt("timeLeft" + appWidgetId, -1).commit();
resetWidgetAlarm(appWidgetId);
finish();
}
});
}
protectedvoid resetWidgetAlarm(int widgetId) {
Intent intent = new Intent(this, BikeWidgetProvider.class);
intent.setAction(BikeWidgetProvider.RESET);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
sendBroadcast(intent);
}
}