Java Code Examples for android.appwidget.AppWidgetManager#INVALID_APPWIDGET_ID
The following examples show how to use
android.appwidget.AppWidgetManager#INVALID_APPWIDGET_ID .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigActivity.java From OmniList with GNU Affero General Public License v3.0 | 6 votes |
private void handleArguments() { Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); return; } SharedPreferences sharedPreferences = getApplication().getSharedPreferences( Constants.PREFS_NAME, Context.MODE_MULTI_PROCESS); long categoryCode = sharedPreferences.getLong( Constants.PREF_WIDGET_CATEGORY_CODE_PREFIX + String.valueOf(mAppWidgetId), 0); if (categoryCode != 0) { fetchCategory(categoryCode); } }
Example 2
Source File: DynamicWidgetActivity.java From dynamic-support with Apache License 2.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set the result to CANCELED. This will cause the widget host to cancel // out of the widget placement if they press the back button. setResult(RESULT_CANCELED); // Find the widget id from the intent. Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); mUpdateWidget = extras.getBoolean( DynamicIntent.EXTRA_WIDGET_UPDATE, false); } // If they gave us an intent without the widget id, just bail. if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finishActivity(); } }
Example 3
Source File: AccountWidgetProvider.java From CSipSimple with GNU General Public License v3.0 | 6 votes |
/** * Receives and processes a button pressed intent or state change. * * @param context * @param intent Indicates the pressed button. */ @Override public void onReceive(final Context context, Intent intent) { String act = intent.getAction(); if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(act)) { final int appWidgetId = intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) { this.onDeleted(context, new int[] { appWidgetId }); } } else if (SipManager.ACTION_SIP_REGISTRATION_CHANGED.equals(act) || SipManager.ACTION_SIP_ACCOUNT_CHANGED.equals(act)) { //Thread t = new Thread() { // public void run() { updateWidget(context); // }; //}; //t.start(); } super.onReceive(context, intent); }
Example 4
Source File: WidgetConfigActivity.java From materialistic with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setResult(RESULT_CANCELED); if (getIntent().getExtras() == null || (mAppWidgetId = getIntent().getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID)) == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); return; } supportRequestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_widget_config); if (savedInstanceState == null) { Bundle args = new Bundle(); args.putInt(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); getSupportFragmentManager() .beginTransaction() .replace(R.id.widget_preferences, Fragment.instantiate(this, WidgetConfigurationFragment.class.getName(), args), WidgetConfigurationFragment.class.getName()) .commit(); } //noinspection ConstantConditions findViewById(R.id.button_ok).setOnClickListener(v -> configure()); }
Example 5
Source File: ShotAppWidgetConfigure.java From droidddle with Apache License 2.0 | 6 votes |
@Override protected void onMyCreate(Bundle savedInstanceState) { // Set the result to CANCELED. This will cause the widget host to cancel // out of the widget placement if they press the back button. setResult(RESULT_CANCELED); setContentView(R.layout.activity_shot_app_widget_config); ButterKnife.inject(this); String[] entries = getResources().getStringArray(R.array.refresh_entries); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, entries); mListView.setAdapter(adapter); mListView.setOnItemClickListener(this); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); } }
Example 6
Source File: AppSettings.java From SuntimesWidget with GNU General Public License v3.0 | 6 votes |
public static int themePrefToStyleId( Context context, String themeName, SuntimesRiseSetData data ) { int styleID = R.style.AppTheme_Dark; if (themeName != null) { //noinspection IfCanBeSwitch if (themeName.equals(THEME_LIGHT)) { styleID = R.style.AppTheme_Light; } else if (themeName.equals(THEME_DARK)) { styleID = R.style.AppTheme_Dark; } else if (themeName.equals(THEME_DAYNIGHT)) { if (data == null) { data = new SuntimesRiseSetData(context, AppWidgetManager.INVALID_APPWIDGET_ID); data.initCalculator(context); } styleID = (data.isDay() ? R.style.AppTheme_Light : R.style.AppTheme_Dark); } } return styleID; }
Example 7
Source File: SuntimesConfigActivity0.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle icicle) { setTheme(AppSettings.loadTheme(this)); GetFixUI.themeIcons(this); super.onCreate(icicle); initLocale(this); setResult(RESULT_CANCELED); setContentView(R.layout.layout_settings); Context context = SuntimesConfigActivity0.this; Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); reconfigure = extras.getBoolean(EXTRA_RECONFIGURE, false); } if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { Log.w("onCreate", "Invalid widget ID! returning early."); finish(); overridePendingTransition(R.anim.transition_cancel_in, R.anim.transition_cancel_out); return; } Intent cancelIntent = new Intent(); cancelIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); setResult(RESULT_CANCELED, cancelIntent); WidgetThemes.initThemes(context); initViews(context); loadSettings(context); }
Example 8
Source File: QuickActivity.java From OmniList with GNU Affero General Public License v3.0 | 5 votes |
private void handleIntent(Intent intent) { String action = intent.getAction(); LogUtils.d("action:" + action); if (TextUtils.isEmpty(action)) { finish(); return; } long categoryCode = 0; int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID; Bundle extras = intent.getExtras(); if (extras != null && extras.containsKey(Constants.INTENT_WIDGET)) { mAppWidgetId = extras.getInt(Constants.INTENT_WIDGET, AppWidgetManager.INVALID_APPWIDGET_ID); } if (mAppWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) { SharedPreferences sharedPreferences = getApplication().getSharedPreferences( Constants.PREFS_NAME, Context.MODE_MULTI_PROCESS); categoryCode = sharedPreferences.getLong( Constants.PREF_WIDGET_CATEGORY_CODE_PREFIX + String.valueOf(mAppWidgetId), 0); } if (categoryCode == 0) { /* Should show category picker dialog at first */ ToastUtils.makeToast(R.string.widget_pick_category_at_first); showCategoryPicker(); } else { /* Fetch category from database */ fetchCategory(categoryCode); } }
Example 9
Source File: OverclockingWidgetConfigureActivity.java From rpicheck with MIT License | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // init logging LoggingHelper.initLogging(OverclockingWidgetConfigureActivity.this); // Set the result to CANCELED. This will cause the widget host to cancel // out of the widget placement if the user presses the back button. setResult(RESULT_CANCELED); // Find the widget id from the intent. Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } // If this activity was started with an intent without an app widget ID, finish with an error. if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); return; } this.getSupportActionBar().setTitle(getString(R.string.widget_configure_title)); deviceDbHelper = new DeviceDbHelper(this); final int deviceCount = initSpinners(); if (deviceCount == 0) { // show Toast to add a device first Toast.makeText(this, getString(R.string.widget_add_no_device), Toast.LENGTH_LONG).show(); finish(); return; } linLayoutCustomInterval.setVisibility(View.GONE); }
Example 10
Source File: ClockWidgetConfigureActivity.java From Travel-Mate with MIT License | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); mContext = this; // Set the result to CANCELED. This will cause the widget host to cancel // out of the widget placement if the user presses the back button. setResult(RESULT_CANCELED); setContentView(R.layout.clock_widget_configure); //mAppWidgetText = (EditText) findViewById(R.id.appwidget_text); findViewById(R.id.add_button).setOnClickListener(mOnClickListener); // Find the widget id from the intent. Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } // If this activity was started with an intent without an app widget ID, finish with an error. if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); return; } //Setup Spinner for Timezone IDs String[] timezoneIDs = TimeZone.getAvailableIDs(); mTimeZoneSpinner = (Spinner) findViewById(R.id.spinnerTimeZoneIDs); ArrayAdapter<String> mTZAdpter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, timezoneIDs); mTZAdpter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mTimeZoneSpinner.setAdapter(mTZAdpter); mTimeZoneSpinner.setOnItemSelectedListener(this); }
Example 11
Source File: StickyNoteWidgetConfigureActivity.java From kolabnotes-android with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Set the result to CANCELED. This will cause the widget host to cancel // out of the widget placement if the user presses the back button. setResult(RESULT_CANCELED); setContentView(R.layout.sticky_note_widget_configure); findViewById(R.id.add_button).setOnClickListener(mOnClickListener); noteRepository = new NoteRepository(this); accountSpinner = (Spinner) findViewById(R.id.spinner_account); noteSpinner = (Spinner) findViewById(R.id.spinner_note); localAccountName = getResources().getString(R.string.drawer_account_local); // Find the widget id from the intent. Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } // If this activity was started with an intent without an app widget ID, finish with an error. if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); return; } mAccountManager = AccountManager.get(this); initSpinners(); }
Example 12
Source File: MimiWidgetConfigureActivity.java From mimi-reader with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Set the result to CANCELED. This will cause the widget host to cancel // out of the widget placement if the user presses the back button. setResult(RESULT_CANCELED); setContentView(R.layout.mimi_widget_configure); mAppWidgetText = (EditText) findViewById(R.id.appwidget_text); findViewById(R.id.add_button).setOnClickListener(mOnClickListener); // Find the widget id from the intent. Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } // If this activity was started with an intent without an app widget ID, finish with an error. if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); return; } mAppWidgetText.setText(loadTitlePref(MimiWidgetConfigureActivity.this, mAppWidgetId)); }
Example 13
Source File: ExampleAppWidgetConfigure.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Set the result to CANCELED. This will cause the widget host to cancel // out of the widget placement if they press the back button. setResult(RESULT_CANCELED); // Set the view layout resource to use. setContentView(R.layout.appwidget_configure); // Find the EditText mAppWidgetPrefix = (EditText)findViewById(R.id.appwidget_prefix); // Bind the action for the save button. findViewById(R.id.save_button).setOnClickListener(mOnClickListener); // Find the widget id from the intent. Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } // If they gave us an intent without the widget id, just bail. if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); } mAppWidgetPrefix.setText(loadTitlePref(ExampleAppWidgetConfigure.this, mAppWidgetId)); }
Example 14
Source File: ShortcutWidgetProvider.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
/** * Receives and processes a button pressed intent or state change. * * @param context * @param intent Indicates the pressed button. */ @Override public void onReceive(final Context context, Intent intent) { String act = intent.getAction(); if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(act)) { final int appWidgetId = intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) { this.onDeleted(context, new int[] { appWidgetId }); } } super.onReceive(context, intent); }
Example 15
Source File: WidgetThemeListActivity.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
private void initData(Context context) { data = new SuntimesRiseSetData(context, AppWidgetManager.INVALID_APPWIDGET_ID); // use app configuration data.setCompareMode(WidgetSettings.CompareMode.TOMORROW); data.setTimeMode(WidgetSettings.TimeMode.OFFICIAL); data.calculate(); SuntimesRiseSetData noonData = new SuntimesRiseSetData(data); noonData.setTimeMode(WidgetSettings.TimeMode.NOON); noonData.calculate(); data.linkData(noonData); }
Example 16
Source File: WeatherWidgetThreeDayForecastConfigureActivity.java From privacy-friendly-weather with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Set the result to CANCELED. This will cause the widget host to cancel // out of the widget placement if the user presses the back button. setResult(RESULT_CANCELED); Log.i("TGL", "second widget... load"); setContentView(R.layout.weather_widget_configure); findViewById(R.id.add_button).setOnClickListener(mOnClickListener); // Find the widget id from the intent. Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } // If this activity was started with an intent without an app widget ID, finish with an error. if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); return; } mAppWidgetText = (AutoCompleteTextView) findViewById(R.id.appwidget_text); database = PFASQLiteHelper.getInstance(this); generator = new AutoCompleteCityTextViewGenerator(getApplicationContext(), database); generator.generate(mAppWidgetText, 100, EditorInfo.IME_ACTION_DONE, new MyConsumer<City>() { @Override public void accept(City city) { selectedCity = city; } }, new Runnable() { @Override public void run() { handleOk(); } }); }
Example 17
Source File: WeatherWidgetConfigureActivity.java From privacy-friendly-weather with GNU General Public License v3.0 | 4 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Set the result to CANCELED. This will cause the widget host to cancel // out of the widget placement if the user presses the back button. setResult(RESULT_CANCELED); setContentView(R.layout.weather_widget_configure); findViewById(R.id.add_button).setOnClickListener(mOnClickListener); // Find the widget id from the intent. Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } // If this activity was started with an intent without an app widget ID, finish with an error. if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); return; } Log.i("TGL", "onCreate"); mAppWidgetText = (AutoCompleteTextView) findViewById(R.id.appwidget_text); database = PFASQLiteHelper.getInstance(this); generator = new AutoCompleteCityTextViewGenerator(getApplicationContext(), database); generator.generate(mAppWidgetText, 100, EditorInfo.IME_ACTION_DONE, new MyConsumer<City>() { @Override public void accept(City city) { selectedCity = city; } }, new Runnable() { @Override public void run() { handleOk(); } }); }
Example 18
Source File: TodayWidgetConfigureActivity.java From ETSMobile-Android2 with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); // Set the result to CANCELED. This will cause the widget host to cancel // out of the widget placement if the user presses the back button. setResult(RESULT_CANCELED); setContentView(R.layout.widget_today_configure); setUpActionBar(); mWidgetPreviewLayout = (RelativeLayout) findViewById(R.id.today_widget); prevBtn = findViewById(R.id.widget_prev_day_btn); mWidgetTodaysNameTv = (TextView) findViewById(R.id.widget_todays_name); nextBtn = findViewById(R.id.widget_next_day_btn); syncBtn = (ImageButton) findViewById(R.id.widget_sync_btn); mBgColorSpinner = (Spinner) findViewById(R.id.bg_color_spinner); setUpColorSpinner(mBgColorSpinner, mBgColorSpinnerListener); mBgColorSpinner.setSelection(getSpinnerAdapterPosition(loadBgColorDefaultPref())); mTextColorSpinner = (Spinner) findViewById(R.id.bg_text_color_spinner); setUpColorSpinner(mTextColorSpinner, mTextColorSpinnerListener); mTextColorSpinner.setSelection(getSpinnerAdapterPosition(loadTextColorDefaultPref())); setUpOpacitySeekBar(); findViewById(R.id.ok_btn).setOnClickListener(mOkBtnOnClickListener); // Find the widget id from the intent. Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } // If this activity was started with an intent without an app widget ID, finish with an error. if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); } }
Example 19
Source File: TwitterFollowerConfigActivity.java From codeexamples-android with Eclipse Public License 1.0 | 4 votes |
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { Log.e("TwitterFollower", "onCreate of ConfigActivity called"); super.onCreate(savedInstanceState); // Set the result to CANCELED. This will cause the widget host to cancel // out of the widget placement if they press the back button. setResult(RESULT_CANCELED); setContentView(R.layout.configuration); // Find the widget id from the intent. Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } Log.e("TwitterFollower", "WidgetId " + mAppWidgetId); // If they gave us an intent without the widget id, just bail. if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); } Button button = (Button) findViewById(R.id.finish); user = (TextView) findViewById(R.id.twitteruser); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Context context = TwitterFollowerConfigActivity.this; String userName = user.getText().toString(); userName = userName.replaceAll("@", ""); saveTitlePref(context, mAppWidgetId, userName); Log.e("TwitterFollower", "Config Saved Preference"); // Push widget update to surface with newly set prefix AppWidgetManager appWidgetManager = AppWidgetManager .getInstance(context); Log.e(TAG, "Update Widget from config"); // Trigger the update TwitterFollowerReceiver.updateAppWidget( TwitterFollowerConfigActivity.this, appWidgetManager, mAppWidgetId); // Make sure we pass back the original appWidgetId Intent resultValue = new Intent(); resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); setResult(RESULT_OK, resultValue); finish(); } }); }
Example 20
Source File: PSWidgetOnCreate.java From PacketSender-Android with MIT License | 3 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setResult(RESULT_CANCELED); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt( AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } // If they gave us an intent without the widget id, just bail. if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { finish(); } setContentView(R.layout.activity_pswidget_on_create); if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()) .commit(); } }