static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) { Log.d(TAG, "updateAppWidget ID:" + appWidgetId); boolean isContentProviderInstalled = isPackageInstalled(CONTENT_PROVIDER_PACKAGE, context); /* Log.d(TAG, "is On This Day installed:"+isContentProviderInstalled); Log.d(TAG, "is ContentProviderInstalled:"+DataFetcher.isProviderInstalled(context)); */ // save current Lang Resources res = context.getResources(); Configuration conf = res.getConfiguration(); String currentLang = conf.locale.getLanguage(); // get settings lang String settingLang = SettingsActivity.loadPrefs(context, appWidgetId); if (settingLang == null || settingLang.isEmpty()) { settingLang = currentLang; } Date currentDate = new Date(); RemoteViews rv; if (!isContentProviderInstalled) { // no content provider rv = new RemoteViews(context.getPackageName(), R.layout.plz_install_widget_layout); // Create an Intent to launch Play Market Intent intent; // TODO check is market:// parsed try { intent = new Intent( Intent.ACTION_VIEW, Uri.parse("market://details?id=" + CONTENT_PROVIDER_PACKAGE)); } catch (android.content.ActivityNotFoundException anfe) { intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "https://play.google.com/store/apps/details?id=" + CONTENT_PROVIDER_PACKAGE)); } PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); rv.setOnClickPendingIntent(R.id.installView, pendingIntent); } else { rv = new RemoteViews(context.getPackageName(), R.layout.atd_widget_layout); setTitle(rv, context, settingLang, currentDate); // start service for getData and create Views setList(rv, context, settingLang, currentDate, appWidgetId); } // // Do additional processing specific to this app widget... // appWidgetManager.updateAppWidget(appWidgetId, rv); }
private boolean isNeedUpdate(int appWidgetId, Context context) { String settingLang = SettingsActivity.loadPrefs(context, appWidgetId); if (settingLang == null || settingLang.isEmpty()) { return false; } return true; }