Android Open Source - CalendarWidget App Widget Configure Activity






From Project

Back to project page CalendarWidget.

License

The source code is released under:

MIT License

If you think the Android project CalendarWidget 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

package co.sfng.calendarwidget;
/*www.j  a v a 2  s .c  o  m*/
import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;


public class AppWidgetConfigureActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Initialize SharedPreferences with default values if it hasn't already.
        PreferenceManager.setDefaultValues(getApplicationContext(), R.xml.preferences, false);

        setContentView(R.layout.appwidget_settings);
        findViewById(R.id.ok_button).setOnClickListener(mOnClickListener);
    }


    @Override
    protected void onPause() {
        super.onPause();
        refreshWidgets();
    }

    private OnClickListener mOnClickListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            refreshWidgets();
            finish();
        }
    };

    private void refreshWidgets() {
        // Obtain all app widget IDs.
        Context context = getApplicationContext();
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        ComponentName cn = new ComponentName(context, CalendarWidgetProvider.class);
        int[] appWidgetIds = appWidgetManager.getAppWidgetIds(cn);

        if (appWidgetIds != null && appWidgetIds.length != 0) {
            // Broadcast update action to all running app widgets.
            Intent intent = new Intent(context, CalendarWidgetProvider.class);
            intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
            context.sendBroadcast(intent);
        }
    }

}




Java Source Code List

co.sfng.calendarwidget.AppWidgetConfigureActivity.java
co.sfng.calendarwidget.CalendarWidgetProvider.java
co.sfng.calendarwidget.DayOfWeekHelper.java
co.sfng.calendarwidget.ResourceHelper.java
co.sfng.calendarwidget.SettingsFragment.java