List of usage examples for android.appwidget AppWidgetManager INVALID_APPWIDGET_ID
int INVALID_APPWIDGET_ID
To view the source code for android.appwidget AppWidgetManager INVALID_APPWIDGET_ID.
Click Source Link
From source file:com.ultrafunk.network_info.config.ConfigActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*//from w w w .jav a 2 s .c o m ToDo: So we can show the ConfigActivity when started from a lock screen widget getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); */ // 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_config); // Find the widget id from the intent. Bundle extras = getIntent().getExtras(); if (extras != null) appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) finish(); appAppWidgetManager = AppWidgetManager.getInstance(this); widgetConfig = new WidgetConfig(this); widgetConfig.read(appWidgetId); // ToDo: Needs to change if/when the ConfigActivity is started from a widget or home screen widgetConfig.setBothWidgets(true); TextView configurationTextView = (TextView) findViewById(R.id.configurationTextView); configurationTextView.setText( (isLockscreenWidget(appAppWidgetManager, appWidgetId) ? getString(R.string.lockscreen_configuration) : getString(R.string.homescreen_configuration))); initShowWidgetView(); initMobileSettingsScreenView(); initLockscreenGravityView(); initTransparencyView(); initOkAndCancelButtons(); }
From source file:name.gumartinm.weather.information.widget.WidgetIntentService.java
@Override protected void onHandleIntent(final Intent intent) { final int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); final boolean isRefreshAppWidget = intent.getBooleanExtra("refreshAppWidget", false); if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { // Nothing to do. Something went wrong. return;//from www .j av a 2s. c o m } final DatabaseQueries query = new DatabaseQueries(this.getApplicationContext()); final WeatherLocation weatherLocation = query.queryDataBase(); if (weatherLocation == null) { // Nothing to do. Show error. final RemoteViews view = this.makeViewOnError(appWidgetId); this.updateWidget(view, appWidgetId); return; } if (!isRefreshAppWidget) { final RemoteViews view = this.makeViewOnNotRefresh(weatherLocation, appWidgetId); this.updateWidget(view, appWidgetId); } else { final RemoteViews view = this.makeViewOnRefresh(weatherLocation, appWidgetId); this.updateWidget(view, appWidgetId); } }
From source file:com.gadelkareem.serverload.ServerLoadConfig.java
@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);//from w ww . j a v a 2 s. c o m // Set the view layout resource to use. setContentView(R.layout.serverload_config); // Find the EditText URL_Input = (EditText) findViewById(R.id.URL); servername_Input = (EditText) findViewById(R.id.servername); // 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) { appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } // If they gave us an intent without the widget id, just bail. if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { Log.d(TAG, "Widget id is invalid"); finish(); } URL_Input.setText(loadPref(ServerLoadConfig.this, appWidgetId, "URL")); servername_Input.setText(loadPref(ServerLoadConfig.this, appWidgetId, "servername")); }
From source file:au.com.wallaceit.reddinator.Rservice.java
public ListRemoteViewsFactory(Context context, Intent intent) { this.mContext = context; appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); global = ((GlobalObjects) context.getApplicationContext()); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); //System.out.println("New view factory created for widget ID:"+appWidgetId); // Set thread network policy to prevent network on main thread exceptions. StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy);/*w w w. ja v a2 s . com*/ // if this is a user request (apart from 'loadmore') or an auto update, do not attempt to load cache. // when a user clicks load more and a new view factory needs to be created we don't want to bypass cache, we want to load the cached items int loadType = global.getLoadType(); if (!global.getBypassCache() || loadType == GlobalObjects.LOADTYPE_LOADMORE) { // load cached data data = global.getFeed(mSharedPreferences, appWidgetId); if (data.length() != 0) { titleFontSize = mSharedPreferences.getString(context.getString(R.string.widget_theme_pref), "16"); try { lastItemId = data.getJSONObject(data.length() - 1).getJSONObject("data").getString("name"); } catch (JSONException e) { lastItemId = "0"; // Could not get last item ID; perform a reload next time and show error view :( e.printStackTrace(); } if (loadType == GlobalObjects.LOADTYPE_LOAD) { loadCached = true; // this isn't a loadmore request, the cache is loaded and we're done //System.out.println("Cache loaded, no user request received."); } } else { loadReddits(false); // No feed items; do a reload. } } else { data = new JSONArray(); // set empty data to prevent any NPE } }
From source file:ru.kaefik.isaifutdinov.an_weather_widget.ConfigActivity.java
@Override protected void onStart() { super.onStart(); Log.i(TAG_SERVICE, "onStart ConfigActivity"); //----------------------- mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID; Intent intent = getIntent();//from w ww .j a v a 2s . c om Bundle extras = intent.getExtras(); if (extras != null) { mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); } final Context context = this; //----------------------- // ?? ? ?? mNameCity.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String cityNameString = adapter.getCityModel(position); Log.i(TAG_SERVICE, " OnItemClick ConfigActivity -> " + cityNameString + " id : " + String.valueOf(mAppWidgetId)); saveStringParametersToCfg(context, String.valueOf(mAppWidgetId), cityNameString); Intent resulValue = new Intent(AnWeatherWidget.CLICK_WIDGET_BUTTON); resulValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId); // ? ConfigActivity try { AnWeatherWidget.updateAppWidget(context, AppWidgetManager.getInstance(context), mAppWidgetId); } catch (JSONException e) { e.printStackTrace(); } setResult(RESULT_OK, resulValue); finish(); } }); }
From source file:com.gaze.webpaser.StackWidgetService.java
public StackRemoteViewsFactory(Context context, Intent intent) { mContext = context; mAppWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); }
From source file:com.codeskraps.lolo.home.PrefsActivity.java
@Override public void onBackPressed() { if (BuildConfig.DEBUG) Log.d(TAG, "onBackPressed"); // This will be called either automatically for you on 2.0 // or later, or by the code above on earlier versions of the // platform./*w w w . ja va2 s . co m*/ if (Constants.CONFIGURE_ACTION.equals(getIntent().getAction())) { Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras != null) { int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); Intent result = new Intent(); result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); setResult(RESULT_OK, result); } } sendBroadcast(new Intent(Constants.FORCE_WIDGET_UPDATE)); super.onBackPressed(); }
From source file:org.jraf.android.hellomundo.app.appwidget.webcam.WebcamAppWidgetActionsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d("intent=" + StringUtil.toString(getIntent())); Bundle extras = getIntent().getExtras(); if (extras != null) { mAppWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); mWebcamId = extras.getLong(EXTRA_WEBCAM_ID, Constants.PREF_SELECTED_WEBCAM_ID_DEFAULT); mCurrentWebcamId = extras.getLong(EXTRA_CURRENT_WEBCAM_ID, Constants.PREF_SELECTED_WEBCAM_ID_DEFAULT); }/*w w w. j a v a 2s.co m*/ if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) { Log.d("Received an invalid appwidget id: abort"); finish(); return; } new TaskFragment(new Task<MainActivity>() { private String mName; private String mLocation; private String mTimeZone; private String mPublicId; private WebcamType mType; @Override protected void doInBackground() throws Throwable { WebcamCursor cursor = new WebcamSelection().id(mCurrentWebcamId).query(getContentResolver()); try { if (cursor == null || !cursor.moveToFirst()) { throw new Exception("Could not find webcam with id=" + mCurrentWebcamId); } mName = cursor.getName(); mLocation = cursor.getLocation(); mTimeZone = cursor.getTimezone(); mPublicId = cursor.getPublicId(); mType = cursor.getType(); } finally { if (cursor != null) cursor.close(); } } @Override protected void onPostExecuteOk() { String title = mName; if (mType != WebcamType.USER) { String location = mLocation; boolean specialCam = Constants.SPECIAL_CAMS.contains(mPublicId); if (!specialCam) { location += " - " + DateTimeUtil .getCurrentTimeForTimezone(WebcamAppWidgetActionsActivity.this, mTimeZone); } title += ", " + location; } ActionsDialogFragment actionsDialogFragment = ActionsDialogFragment.newInstance(title); actionsDialogFragment.show(getSupportFragmentManager(), FRAGMENT_DIALOG); } }).execute(getSupportFragmentManager()); }
From source file:com.ultrafunk.network_info.receiver.WifiStatusReceiver.java
@Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); // Log.e(this.getClass().getSimpleName(), "onReceive(): " + action); updateWifiViews = true;//from w w w .j a v a2s . c o m wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); wifiState = wifiManager.getWifiState(); wifiInfo = wifiManager.getConnectionInfo(); if ((wifiState == WifiManager.WIFI_STATE_ENABLED) && (wifiInfo.getIpAddress() == 0)) detailedState = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState()); if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) { if (isConnectionReady(intent)) { String securityString = WifiUtils.getSecurityString(context, wifiManager, wifiInfo.getBSSID()); NetworkStateService.setWifiSecurityString(securityString); detailsString = context.getString(R.string.security) + ": " + securityString; Intent serviceIntent = new Intent(context, NetworkStateService.class); serviceIntent.setAction(Constants.ACTION_WIFI_CONNECTED); context.startService(serviceIntent); } partiallyUpdateWidgets(context); } else if (WifiManager.WIFI_STATE_CHANGED_ACTION.equals(action) || Constants.ACTION_WIFI_SCANNING.equals(action)) { partiallyUpdateWidgets(context); } else if (Intent.ACTION_SCREEN_ON.equals(action) || Constants.ACTION_WIFI_LINK_SPEED.equals(action)) { if (isConnected()) { setDetailsString(context); partiallyUpdateWidgets(context); } } else if (Constants.ACTION_UPDATE_WIDGET.equals(action)) { if (isConnected()) setDetailsString(context); partiallyUpdateWidget(context, AppWidgetManager.getInstance(context), intent.getIntExtra(Constants.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID)); } }
From source file:com.forrestguice.suntimeswidget.notes.SuntimesNotes1.java
/** * Switch to the next note (in ordered set of notes). * @return true if the note was changed, false otherwise *//* w w w .j av a 2 s . c om*/ @Override public boolean showNextNote() { if (dataset.isCalculated()) { Calendar now = dataset.now(); if (dataset.isNight(now)) { // show next "rising" note SolarEvents currentNoteMode = WidgetSettings.loadTimeNoteRisePref(context, AppWidgetManager.INVALID_APPWIDGET_ID); int currentNote = currentNoteMode.ordinal(); int nextNote = 0; if (hasNextRiseNote(currentNote)) { nextNote = currentNote + 1; } SolarEvents nextNoteMode = SolarEvents.values()[nextNote]; WidgetSettings.saveTimeNoteRisePref(context, AppWidgetManager.INVALID_APPWIDGET_ID, nextNoteMode); //Log.d("showNextRiseNote", "... current = " + currentNote + ", next = " + nextNote + ", mode = " + nextNoteMode.name()); } else { // show next "setting" note SolarEvents currentNoteMode = WidgetSettings.loadTimeNoteSetPref(context, AppWidgetManager.INVALID_APPWIDGET_ID); int currentNote = currentNoteMode.ordinal(); int nextNote = 0; if (hasNextSetNote(currentNote)) { nextNote = currentNote + 1; } SolarEvents nextNoteMode = SolarEvents.values()[nextNote]; WidgetSettings.saveTimeNoteSetPref(context, AppWidgetManager.INVALID_APPWIDGET_ID, nextNoteMode); //Log.d("showNextSetNote", "... current = " + currentNote + ", next = " + nextNote + ", mode = " + nextNoteMode.name()); } updateNote(context, now, NoteChangedListener.TRANSITION_NEXT); return true; } else { Log.w("showNextNote", "called before data was calculated!"); return false; } }