コード例 #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);
      }
    }
コード例 #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;
  }
コード例 #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);
    }
  }
コード例 #4
0
 public Intent getIntent() {
   ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mHistoryFileName);
   return dataModel.getIntent();
 }
コード例 #5
0
 @Override
 public void onClick(View view) {
   ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mHistoryFileName);
   chooseActivity(dataModel.getActivityIndex(dataModel.getDefaultActivity()));
 }
コード例 #6
0
 public void setIntent(Intent intent) {
   ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mHistoryFileName);
   dataModel.setIntent(intent);
 }