Пример #1
1
    private boolean addUriShortcut(SQLiteDatabase db, ContentValues values, TypedArray a) {
      Resources r = mContext.getResources();

      final int iconResId = a.getResourceId(R.styleable.Favorite_icon, 0);
      final int titleResId = a.getResourceId(R.styleable.Favorite_title, 0);

      Intent intent;
      String uri = null;
      try {
        uri = a.getString(R.styleable.Favorite_uri);
        intent = Intent.parseUri(uri, 0);
      } catch (URISyntaxException e) {
        Log.w(TAG, "Shortcut has malformed uri: " + uri);
        return false; // Oh well
      }

      if (iconResId == 0 || titleResId == 0) {
        Log.w(TAG, "Shortcut is missing title or icon resource ID");
        return false;
      }

      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      values.put(Favorites.INTENT, intent.toUri(0));
      values.put(Favorites.TITLE, r.getString(titleResId));
      values.put(Favorites.ITEM_TYPE, Favorites.ITEM_TYPE_SHORTCUT);
      values.put(Favorites.SPANX, 1);
      values.put(Favorites.SPANY, 1);
      values.put(Favorites.ICON_TYPE, Favorites.ICON_TYPE_RESOURCE);
      values.put(Favorites.ICON_PACKAGE, mContext.getPackageName());
      values.put(Favorites.ICON_RESOURCE, r.getResourceName(iconResId));

      db.insert(TABLE_FAVORITES, null, values);

      return true;
    }
  @Override
  void onAddToDatabase(Context context, ContentValues values) {
    super.onAddToDatabase(context, values);

    String titleStr = title != null ? title.toString() : null;
    values.put(LauncherSettings.BaseLauncherColumns.TITLE, titleStr);

    String uri =
        promisedIntent != null
            ? promisedIntent.toUri(0)
            : (intent != null ? intent.toUri(0) : null);
    values.put(LauncherSettings.BaseLauncherColumns.INTENT, uri);

    if (customIcon) {
      values.put(
          LauncherSettings.BaseLauncherColumns.ICON_TYPE,
          LauncherSettings.BaseLauncherColumns.ICON_TYPE_BITMAP);
      writeBitmap(values, mIcon);
    } else {
      if (!usingFallbackIcon) {
        writeBitmap(values, mIcon);
      }
      values.put(
          LauncherSettings.BaseLauncherColumns.ICON_TYPE,
          LauncherSettings.BaseLauncherColumns.ICON_TYPE_RESOURCE);
      if (iconResource != null) {
        values.put(LauncherSettings.BaseLauncherColumns.ICON_PACKAGE, iconResource.packageName);
        values.put(LauncherSettings.BaseLauncherColumns.ICON_RESOURCE, iconResource.resourceName);
      }
    }
  }
Пример #3
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    Log.d(TAG, "onUpdate");

    for (int i = 0; i < appWidgetIds.length; i++) {
      int appWidgetId = appWidgetIds[i];

      Intent intent = new Intent(context, StackWidgetService.class);
      intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);

      intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));

      RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
      views.setRemoteAdapter(appWidgetId, R.id.stack_view, intent);
      views.setEmptyView(R.id.stack_view, R.id.empty_view);

      Intent toastIntent = new Intent(context, FootballScoreWidget.class);
      toastIntent.setAction(FootballScoreWidget.OPEN_ACTIVITY_ACTION);
      toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
      intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
      PendingIntent toastPendingIntent =
          PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
      views.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);

      appWidgetManager.updateAppWidget(appWidgetId, views);
    }

    super.onUpdate(context, appWidgetManager, appWidgetIds);
  }
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    // update each of the widgets with the remote adapter
    for (int i = 0; i < appWidgetIds.length; ++i) {

      // Here we setup the intent which points to the StackViewService which will
      // provide the views for this collection.
      Intent intent = new Intent(context, StackWidgetService.class);
      intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
      // When intents are compared, the extras are ignored, so we need to embed the extras
      // into the data so that the extras will not be ignored.
      intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
      RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
      rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);

      // The empty view is displayed when the collection has no items. It should be a sibling
      // of the collection view.
      rv.setEmptyView(R.id.stack_view, R.id.empty_view);

      // Here we setup the a pending intent template. Individuals items of a collection
      // cannot setup their own pending intents, instead, the collection as a whole can
      // setup a pending intent template, and the individual items can set a fillInIntent
      // to create unique before on an item to item basis.
      Intent toastIntent = new Intent(context, StackWidgetProvider.class);
      toastIntent.setAction(StackWidgetProvider.TOAST_ACTION);
      toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
      intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
      PendingIntent toastPendingIntent =
          PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
      rv.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);

      appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
  }
  @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    ComponentName thisWidget = new ComponentName(context, Widget4x4Provider.class);
    this.appWidgetIds = appWidgetIds;

    /*
    Set up the intent that starts the LargeWidgetService, which will
    provide the views for this collection.
    */
    Intent serviceIntent = new Intent(context, LargeWidgetService.class);

    // ---Add this app widget to the intent extras---
    serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, thisWidget);
    serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));

    /*
    This adapter connects to a RemoteViewsService through the specified intent.
    This is how you populate the data.
    */
    remoteView =
        new RemoteViews(
            context.getPackageName(), com.eazyigz.RussiaMediaSearch.R.layout.appwidget_4x4);
    //        remoteView.setRemoteAdapter(R.id.listViewWidget, serviceIntent);
    for (int i = 0; i < appWidgetManager.getAppWidgetIds(thisWidget).length; ++i) {
      remoteView.setRemoteAdapter(
          appWidgetManager.getAppWidgetIds(thisWidget)[i], R.id.listViewWidget, serviceIntent);
    }
    remoteView.setEmptyView(R.id.listViewWidget, R.id.row_empty_label_widget);

    final Intent onClickIntent = new Intent(context, Widget4x4Provider.class);
    onClickIntent.setAction(Widget4x4Provider._listClickAction);
    onClickIntent.setData(Uri.parse(onClickIntent.toUri(Intent.URI_INTENT_SCHEME)));
    final PendingIntent listClickPendingIntent =
        PendingIntent.getBroadcast(context, 0, onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
      remoteView.setPendingIntentTemplate(R.id.listViewWidget, listClickPendingIntent);

    setupLauncherShortcut(context, remoteView);
    setupRussianVoiceSearch(context, remoteView);
    setupEnglishVoiceSearch(context, remoteView);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
      appWidgetManager.notifyAppWidgetViewDataChanged(
          appWidgetManager.getAppWidgetIds(thisWidget), R.id.listViewWidget);
    appWidgetManager.updateAppWidget(thisWidget, remoteView);

    super.onUpdate(context, appWidgetManager, appWidgetManager.getAppWidgetIds(thisWidget));
  }
Пример #6
0
 private void extractDataForPlaylist(Object[] paramArrayOfObject) {
   Cursor localCursor = getWrappedCursor();
   long l = localCursor.getLong(0);
   String str1 = localCursor.getString(3);
   String str2 = MusicContent.PlaylistArt.getPlaylistArtUri(l, -1, -1).toString();
   Uri localUri1 = XdiContentProvider.BASE_URI;
   String str3 = "details/playlists/" + l;
   Uri localUri2 = Uri.withAppendedPath(localUri1, str3);
   Intent localIntent = new Intent("com.google.android.xdi.action.DETAIL", localUri2);
   Resources localResources = this.mContext.getResources();
   Object[] arrayOfObject = new Object[1];
   Integer localInteger1 = Integer.valueOf(0);
   arrayOfObject[0] = localInteger1;
   String str4 = localResources.getQuantityString(2131623940, 0, arrayOfObject);
   ProjectionMap localProjectionMap1 = this.mProjectionMap;
   Integer localInteger2 = Integer.valueOf(localCursor.getPosition() + 1);
   localProjectionMap1.writeValueToArray(paramArrayOfObject, "_id", localInteger2);
   ProjectionMap localProjectionMap2 = this.mProjectionMap;
   Integer localInteger3 = Integer.valueOf(4);
   localProjectionMap2.writeValueToArray(paramArrayOfObject, "parent_id", localInteger3);
   this.mProjectionMap.writeValueToArray(paramArrayOfObject, "display_name", str1);
   this.mProjectionMap.writeValueToArray(paramArrayOfObject, "display_description", str4);
   this.mProjectionMap.writeValueToArray(paramArrayOfObject, "image_uri", str2);
   this.mProjectionMap.writeValueToArray(paramArrayOfObject, "width", null);
   this.mProjectionMap.writeValueToArray(paramArrayOfObject, "height", null);
   ProjectionMap localProjectionMap3 = this.mProjectionMap;
   String str5 = localIntent.toUri(1);
   localProjectionMap3.writeValueToArray(paramArrayOfObject, "intent_uri", str5);
   ProjectionMap localProjectionMap4 = this.mProjectionMap;
   Integer localInteger4 = Integer.valueOf(0);
   localProjectionMap4.writeValueToArray(paramArrayOfObject, "music_trackCount", localInteger4);
 }
Пример #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Global.debugMemory(mDebugPrefix, "onCreate");
    super.onCreate(savedInstanceState);
    final Intent intent = getIntent();
    if (Global.debugEnabled && (intent != null)) {
      Log.d(
          Global.LOG_CONTEXT, mDebugPrefix + "onCreate " + intent.toUri(Intent.URI_INTENT_SCHEME));
    }
    setContentView(R.layout.activity_gallery_filter);
    this.mFilterValue = new FilterValue();
    onCreateButtos();

    GalleryFilterParameter filter =
        (savedInstanceState == null)
            ? getFilter(this.getIntent())
            : GalleryFilterParameter.parse(
                savedInstanceState.getString(FILTER_VALUE, ""), new GalleryFilterParameter());

    if (filter != null) {
      mFilter = filter;
      toGui(mFilter);
      mFilterValue.showLatLon(filter.isNonGeoOnly());
    }

    bookmarkController = new BookmarkController(this);
  }
Пример #8
0
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

    for (int i = 0; i < appWidgetIds.length; i++) {
      // Setup the widget, and data source / adapter
      Intent svcIntent = new Intent(context, DDWidgetService.class);

      svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
      svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));

      RemoteViews widget;

      SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);

      if (sp.getString("theme", "Light").equals("Light")) {
        widget = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
      } else {
        widget = new RemoteViews(context.getPackageName(), R.layout.widget_layout_dark);
      }

      widget.setRemoteAdapter(R.id.listView, svcIntent);

      Intent clickIntent = new Intent(context, ClickHandlingActivity.class);
      PendingIntent clickPI =
          PendingIntent.getActivity(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);

      widget.setPendingIntentTemplate(R.id.listView, clickPI);

      appWidgetManager.updateAppWidget(appWidgetIds[i], widget);
    }

    super.onUpdate(context, appWidgetManager, appWidgetIds);
  }
Пример #9
0
  private RemoteViews updateWidgetListView(Context context, int appWidgetId) {

    // which layout to show on widget
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout);

    // RemoteViews Service needed to provide adapter for ListView
    Intent svcIntent = new Intent(context, StackWidgetService.class);

    // passing app widget id to that RemoteViews Service
    svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    // setting a unique Uri to the intent

    svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));

    if (FetchDataService.mDataFetchList != null) {

      svcIntent.putExtra("data", FetchDataService.mDataFetchList);
    }

    // setting adapter to listview of the widget
    remoteViews.setRemoteAdapter(appWidgetId, R.id.stack_view, svcIntent);

    // setting an empty view in case of no data
    remoteViews.setEmptyView(R.id.stack_view, R.id.empty_view);

    Intent toastIntent = new Intent(context, StackWidgetProvider.class);
    toastIntent.setAction(StackWidgetProvider.TOAST_ACTION);
    toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    PendingIntent toastPendingIntent =
        PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    remoteViews.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);

    return remoteViews;
  }
  /**
   * @param context
   * @param lang
   * @param date
   * @param appWidgetId If your App Widget setup process can take several seconds (perhaps while
   *     performing web requests) and you require that your process continues, consider starting a
   *     Service in the onUpdate() method.
   */
  private static void setList(
      RemoteViews rv, Context context, String lang, Date date, int appWidgetId) {

    SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
    String dateS = sdf.format(date);

    // Set up the intent that starts the CategoryListRemoteViewsFactory service, which will
    // provide the views for this collection.
    Intent adapter = new Intent(context, CategoryListRemoteViewsFactory.class);
    //        adapter.putExtra(CategoryListRemoteViewsFactory.EXTRA_WIDGET_ID, appWidgetId);
    adapter.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); // TODO???
    adapter.putExtra(CategoryListRemoteViewsFactory.EXTRA_WIDGET_LANG, lang);
    adapter.putExtra(CategoryListRemoteViewsFactory.EXTRA_WIDGET_DATE, dateS);
    adapter.setData(Uri.parse(adapter.toUri(Intent.URI_INTENT_SCHEME)));
    Log.d(TAG, "setRemoteAdapter");
    rv.setRemoteAdapter(R.id.listView, adapter);

    rv.setEmptyView(R.id.listView, R.id.emptyView);

    // This section makes it possible for items to have individualized behavior.
    // It does this by setting up a pending intent template. Individuals items of a collection
    // cannot set up their own pending intents. Instead, the collection as a whole sets
    // up a pending intent template, and the individual items set a fillInIntent
    // to create unique behavior on an item-by-item basis.
    Intent appIntent = new Intent();
    appIntent.setClassName(CONTENT_PROVIDER_PACKAGE, "ru.vodnouho.android.yourday.HomeActivity");
    // Set the action for the intent.
    // When the user touches a particular view, it will have the effect of
    // broadcasting TOAST_ACTION.
    appIntent.setAction(Intent.ACTION_VIEW);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, appIntent, 0);
    rv.setPendingIntentTemplate(R.id.listView, pendingIntent);
  }
  @SuppressWarnings("deprecation")
  public static void updateAppWidget(
      Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
    RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);

    Intent intent = new Intent(context, WidgetService.class);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    rv.setRemoteAdapter(appWidgetId, R.id.list_view, intent);

    Intent onListClickIntent = new Intent(context, WidgetProvider.class);
    onListClickIntent.setAction(ACTION_LIST_CLICK);
    onListClickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    onListClickIntent.setData(Uri.parse(onListClickIntent.toUri(Intent.URI_INTENT_SCHEME)));

    final PendingIntent onListClickPendingIntent =
        PendingIntent.getBroadcast(
            context, 0, onListClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    rv.setPendingIntentTemplate(R.id.list_view, onListClickPendingIntent);

    /*
    Intent intentWidget = new Intent(context, WidgetProvider.class);
    PendingIntent pendingWidgetIntent = PendingIntent.getBroadcast(context, 0, intentWidget, PendingIntent.FLAG_UPDATE_CURRENT);
    rv.setOnClickPendingIntent(R.id.cb_lv_item_read_wrapper, pendingWidgetIntent);
    */

    Intent intentToDoListAct = new Intent(context, NewsReaderListActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intentToDoListAct, 0);
    rv.setOnClickPendingIntent(R.id.tV_widget_header, pendingIntent);

    appWidgetManager.updateAppWidget(appWidgetId, rv);

    if (Constants.debugModeWidget) Log.d(TAG, "updateAppWidget - WidgetID: " + appWidgetId);
  }
Пример #12
0
  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    for (int appWidgetId : appWidgetIds) {
      Intent svcIntent = new Intent(context, WidgetService.class);

      svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
      svcIntent.putExtra(
          AppWidgetManager.EXTRA_CUSTOM_INFO, PrefUtils.getInt(appWidgetId + ".fontsize", 0));
      svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));

      RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.widget);
      widget.setOnClickPendingIntent(
          R.id.feed_icon,
          PendingIntent.getActivity(context, 0, new Intent(context, HomeActivity.class), 0));
      widget.setPendingIntentTemplate(
          R.id.feedsListView,
          PendingIntent.getActivity(context, 0, new Intent(Intent.ACTION_VIEW), 0));

      widget.setRemoteAdapter(R.id.feedsListView, svcIntent);
      widget.setInt(
          R.id.feedsListView,
          "setBackgroundColor",
          PrefUtils.getInt(appWidgetId + ".background", STANDARD_BACKGROUND));

      appWidgetManager.updateAppWidget(appWidgetId, widget);
    }

    super.onUpdate(context, appWidgetManager, appWidgetIds);
  }
  @Override
  public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals("android.appwidget.action.notify")) {
      AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
      int appWidgetIds[] =
          appWidgetManager.getAppWidgetIds(new ComponentName(context, TimeTableProvider.class));

      for (int i = 0; i < appWidgetIds.length; i++) {
        Intent svcIntent = new Intent(context, TimeTableWidget.class);

        svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));

        RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.widget_layout);

        widget.setRemoteAdapter(appWidgetIds[i], R.id.words, svcIntent);

        Intent clickIntent = new Intent(context, MainActivity.class);
        PendingIntent clickPI =
            PendingIntent.getActivity(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT);

        widget.setPendingIntentTemplate(R.id.words, clickPI);

        widget.setTextViewText(R.id.weekday, TimeTableControl.today());
        appWidgetManager.updateAppWidget(appWidgetIds[i], widget);
      }
      appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.words);
    }
    super.onReceive(context, intent);
  }
Пример #14
0
  /**
   * 使用名字和intent 不一定所有的手机都有效,因为国内大部分手机的桌面不是系统原生�?更多请参考{isShortCutExist(Context,String)}
   * 桌面有两种,系统桌面(ROM自带)与第三方桌面,一般只考虑系统自带 第三方桌面如果没有实现系统响应的方法是无法判断的,比如GO桌面
   */
  public boolean isShortCutExist(Context context, String title, Intent intent) {
    boolean result = false;
    try {
      ContentResolver cr = context.getContentResolver();
      Uri uri = getUriFromLauncher(context);
      Cursor c =
          cr.query(
              uri,
              new String[] {"title", "intent"},
              "title=?  and intent=?",
              new String[] {title, intent.toUri(0)},
              null);

      if (c != null && c.getCount() > 0) {
        result = true;
      }
      if (c != null && !c.isClosed()) {
        c.close();
      }
    } catch (Exception ex) {
      result = false;
      ex.printStackTrace();
    }
    return result;
  }
 @SuppressLint("ShowToast")
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode == Activity.RESULT_OK && requestCode == 0) {
     String result = data.toUri(0);
     Toast.makeText(this, result, Toast.LENGTH_LONG);
   }
 }
  void completeSetCustomApp(Intent data) {

    ArrayList<String> temp = parseIntents();
    temp.add(data.toUri(0));

    setIntents(temp);
  }
  private String getFriendlyShortcutName(Intent intent) {
    String activityName = getFriendlyActivityName(intent, true);
    String name = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);

    if (activityName != null && name != null) {
      return activityName + ": " + name;
    }
    return name != null ? name : intent.toUri(0);
  }
 public static void updateNote(Context context) {
   AppWidgetManager manager = AppWidgetManager.getInstance(context);
   int[] ids = manager.getAppWidgetIds(new ComponentName(context, TimetableWidgetProvider.class));
   Intent intent = new Intent(context, TimetableWidgetProvider.class);
   intent.setAction(ACTION_UPDATE_NOTE);
   intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids);
   intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
   context.sendBroadcast(intent);
 }
  void completeSetCustomShortcut(Intent data) {

    Intent intent = (Intent) data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);

    ArrayList<String> temp = parseIntents();
    temp.add(intent.toUri(0));

    setIntents(temp);
  }
Пример #20
0
  public void onReceive(Context context, Intent data) {
    if (!ACTION_INSTALL_SHORTCUT.equals(data.getAction())) {
      return;
    }

    if (DBG) Log.d(TAG, "Got INSTALL_SHORTCUT: " + data.toUri(0));
    PendingInstallShortcutInfo info = new PendingInstallShortcutInfo(data, context);

    queuePendingShortcutInfo(info, context);
  }
Пример #21
0
  private RemoteViews updateWidgetListView(Context context, int appWidgetId) {
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.score_appwidget);

    Intent serviceIntent = new Intent(context, ScoresWidgetService.class);
    serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
    remoteViews.setRemoteAdapter(R.id.widget_lv, serviceIntent);
    remoteViews.setEmptyView(R.id.widget_lv, R.id.empty_view);
    return remoteViews;
  }
 public void configureList(Context context, int widgetId, RemoteViews rv) {
   Intent intent = new Intent(context, EventWidgetService.class);
   intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
   intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
   rv.setRemoteAdapter(R.id.event_list, intent);
   rv.setEmptyView(R.id.event_list, R.id.empty_event_list);
   rv.setPendingIntentTemplate(R.id.event_list, createOpenCalendarEventPendingIntent(context));
   rv.setOnClickFillInIntent(
       R.id.empty_event_list, createOpenCalendarAtDayIntent(context, new DateTime()));
 }
 private void completeSetCustomShortcut(Intent data) {
   Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
   /* preserve shortcut name, we want to restore it later */
   intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME));
   String appUri = intent.toUri(0);
   appUri =
       appUri.replaceAll(
           "com.android.contacts.action.QUICK_CONTACT", "android.intent.action.VIEW");
   mListener.shortcutPicked(appUri, getFriendlyShortcutName(intent), false);
 }
Пример #24
0
  static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
    Intent intent = new Intent(context, WidgetService.class);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));

    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
    remoteViews.setRemoteAdapter(appWidgetId, R.id.fixtures_list, intent);
    remoteViews.setEmptyView(R.id.fixtures_list, R.id.empty_view);

    appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
  }
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    final int N = appWidgetIds.length;

    Log.e("WIDGETPROVIDER", "OnUpdate called");

    // Perform this loop procedure for each App Widget that belongs to this provider
    for (int i = 0; i < N; i++) {
      // Set up the intent that starts the StackViewService, which will
      // provide the views for this collection.
      Intent intent = new Intent(context, WidgetService.class);
      // Add the app widget ID to the intent extras.
      intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
      intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
      // Instantiate the RemoteViews object for the app widget layout.
      RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.appwidget);
      // Set up the RemoteViews object to use a RemoteViews adapter.
      // This adapter connects
      // to a RemoteViewsService  through the specified intent.
      // This is how you populate the data.
      rv.setRemoteAdapter(appWidgetIds[i], R.id.list_view, intent);

      // The empty view is displayed when the collection has no items.
      // It should be in the same layout used to instantiate the RemoteViews
      // object above.
      rv.setEmptyView(R.id.list_view, R.id.empty_view);

      // Here we setup the a pending intent template. Individuals items of a collection
      // cannot setup their own pending intents, instead, the collection as a whole can
      // setup a pending intent template, and the individual items can set a fillInIntent
      // to create unique before on an item to item basis.
      Intent toastIntent = new Intent(context, ScoresAppWidgetProvider.class);
      toastIntent.setAction(TOAST_ACTION);
      toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
      intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
      PendingIntent toastPendingIntent =
          PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
      rv.setPendingIntentTemplate(R.id.list_view, toastPendingIntent);

      appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
    }
  }
Пример #26
0
 protected void launchIntent(Intent intent) {
   if (DBG) Log.d(TAG, "launchIntent " + intent);
   if (intent == null) {
     return;
   }
   try {
     startActivity(intent);
     mSearchActivityView.considerHidingInputMethod();
   } catch (RuntimeException ex) {
     // Since the intents for suggestions specified by suggestion providers,
     // guard against them not being handled, not allowed, etc.
     Log.e(TAG, "Failed to start " + intent.toUri(0), ex);
   }
 }
  private String getFriendlyActivityName(Intent intent, boolean labelOnly) {
    PackageManager pm = mParent.getActivity().getPackageManager();
    ActivityInfo ai = intent.resolveActivityInfo(pm, PackageManager.GET_ACTIVITIES);
    String friendlyName = null;

    if (ai != null) {
      friendlyName = ai.loadLabel(pm).toString();
      if (friendlyName == null && !labelOnly) {
        friendlyName = ai.name;
      }
    }

    return friendlyName != null || labelOnly ? friendlyName : intent.toUri(0);
  }
  public static RemoteViews updateWidgetListView(Context context, int appWidgetId) {

    // which layout to show on widget
    RemoteViews remoteViews =
        new RemoteViews(context.getPackageName(), R.layout.flavor_contact_widget);

    // RemoteViews Service needed to provide adapter for ListView
    Intent svcIntent = new Intent(context, FlavorContactRemoteViewsService.class);
    svcIntent.putExtra(FlavorContactEnums.GROUP_ID, flavorContact.getGroupId());
    svcIntent.putExtra(FlavorContactEnums.CONTACTS, Utilities.getGson(flavorContact.getContacts()));
    // passing app widget id to that RemoteViews Service
    svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    // setting a unique Uri to the intent
    // don't know its purpose to me right now
    svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
    // setting adapter to listview of the widget
    remoteViews.setRemoteAdapter(appWidgetId, R.id.gridView, svcIntent);
    // setting an empty view in case of no data
    remoteViews.setEmptyView(R.id.empty_view, R.id.empty_view);

    // This section makes it possible for items to have individualized behavior.
    // It does this by setting up a pending intent template. Individuals items of a collection
    // cannot set up their own pending intents. Instead, the collection as a whole sets
    // up a pending intent template, and the individual items set a fillInIntent
    // to create unique behavior on an item-by-item basis.
    Intent toastIntent = new Intent(context, FlavorContactsWidget.class);
    // Set the action for the intent.
    // When the user touches a particular view, it will have the effect of
    // broadcasting TOAST_ACTION.
    toastIntent.setAction(FlavorContactsWidget.ACTION_TOAST);
    toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME)));
    PendingIntent toastPendingIntent =
        PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    remoteViews.setPendingIntentTemplate(R.id.gridView, toastPendingIntent);
    return remoteViews;
  }
Пример #29
0
  private void setupFromIntent(Intent intent) {
    if (DBG) Log.d(TAG, "setupFromIntent(" + intent.toUri(0) + ")");
    String corpusName = getCorpusNameFromUri(intent.getData());
    String query = intent.getStringExtra(SearchManager.QUERY);
    Bundle appSearchData = intent.getBundleExtra(SearchManager.APP_DATA);
    boolean selectAll = intent.getBooleanExtra(SearchManager.EXTRA_SELECT_QUERY, false);

    setCorpus(corpusName);
    setQuery(query, selectAll);
    mAppSearchData = appSearchData;

    if (startedIntoCorpusSelectionDialog()) {
      mSearchActivityView.showCorpusSelectionDialog();
    }
  }
Пример #30
0
 @Override
 public void onReceive(Context context, Intent intent) {
   // Extract data included in the Intent
   Log.d(
       TAG,
       "context: "
           + context.getClass().getSimpleName()
           + ", intent: "
           + intent.toUri(Intent.URI_INTENT_SCHEME));
   String text =
       intent.hasExtra(DispatchResponseReceiver.KEY_RESPONSE_MESSAGE)
           ? intent.getStringExtra(DispatchResponseReceiver.KEY_RESPONSE_MESSAGE)
           : "Upload Result Received: " + intent.getDataString();
   makeText(text);
 }