Exemplo n.º 1
0
    private void chooseActivity(int index) {
      if (mOnTargetListener != null) mOnTargetListener.onTargetSelected();

      ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mHistoryFileName);
      Intent launchIntent = dataModel.chooseActivity(index);
      if (launchIntent != null) {
        launchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        mContext.startActivity(launchIntent);
      }
    }
Exemplo n.º 2
0
  @Override
  public View onCreateActionView() {
    // Create the view and set its data model.
    ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mHistoryFileName);
    MenuItemActionView view = new MenuItemActionView(mContext, null);
    view.setActionButtonClickListener(mCallbacks);

    if (dataModel.getHistorySize() > 0) {
      PackageManager packageManager = mContext.getPackageManager();
      ResolveInfo defaultActivity = dataModel.getDefaultActivity();
      view.setActionButton(
          defaultActivity == null ? null : defaultActivity.loadIcon(packageManager));
    }

    return view;
  }
Exemplo n.º 3
0
  @Override
  public void onPrepareSubMenu(SubMenu subMenu) {
    // Clear since the order of items may change.
    subMenu.clear();

    ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mHistoryFileName);
    PackageManager packageManager = mContext.getPackageManager();

    // Populate the sub-menu with a sub set of the activities.
    final int count = dataModel.getActivityCount();
    for (int i = 0; i < count; i++) {
      ResolveInfo activity = dataModel.getActivity(i);
      subMenu
          .add(0, i, i, activity.loadLabel(packageManager))
          .setIcon(activity.loadIcon(packageManager))
          .setOnMenuItemClickListener(mCallbacks);
    }
  }
Exemplo n.º 4
0
 public Intent getIntent() {
   ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mHistoryFileName);
   return dataModel.getIntent();
 }
Exemplo n.º 5
0
 @Override
 public void onClick(View view) {
   ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mHistoryFileName);
   chooseActivity(dataModel.getActivityIndex(dataModel.getDefaultActivity()));
 }
Exemplo n.º 6
0
 public void setIntent(Intent intent) {
   ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mHistoryFileName);
   dataModel.setIntent(intent);
 }