android.content.Intent#ACTION_EDIT源码实例Demo

下面列出了android.content.Intent#ACTION_EDIT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: flutter_contacts   文件: ContactsServicePlugin.java
void openExistingContact(Contact contact) {
  String identifier = contact.identifier;
  try {
    HashMap contactMapFromDevice = getContactByIdentifier(identifier);
    // Contact existence check
    if(contactMapFromDevice != null) {
      Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, identifier);
      Intent intent = new Intent(Intent.ACTION_EDIT);
      intent.setDataAndType(uri, ContactsContract.Contacts.CONTENT_ITEM_TYPE);
      intent.putExtra("finishActivityOnSaveCompleted", true);
      startIntent(intent, REQUEST_OPEN_EXISTING_CONTACT);
    } else {
      finishWithResult(FORM_COULD_NOT_BE_OPEN);
    }
  } catch(Exception e) {
    finishWithResult(FORM_COULD_NOT_BE_OPEN);
  }
}
 
源代码2 项目: call_manage   文件: ContactUtils.java
/**
 * Open contact edit page in default contacts app by contact's id
 *
 * @param activity
 * @param number
 */
public static void openContactToEditByNumber(Activity activity, String number) {
    try {
        long contactId = ContactUtils.getContactByPhoneNumber(activity, number).getContactId();
        Uri uri = ContentUris.withAppendedId(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                contactId);
        Intent intent = new Intent(Intent.ACTION_EDIT);
        intent.setDataAndType(uri, ContactsContract.Contacts.CONTENT_ITEM_TYPE);
        intent.putExtra("finishActivityOnSaveCompleted", true);
        //add the below line
        intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP);
        activity.startActivityForResult(intent, 1);
    } catch (Exception e) {
        Toast.makeText(activity, "Oops there was a problem trying to open the contact :(", Toast.LENGTH_SHORT).show();
    }
}
 
源代码3 项目: shortyz   文件: Scrapers.java
private void postDownloadedNotification(int i, String name, File puzFile) {
    String contentTitle = "Downloaded Puzzle From " + name;

    Intent notificationIntent = new Intent(Intent.ACTION_EDIT, Uri.fromFile(puzFile), context, PlayActivity.class);
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

    Notification not = new NotificationCompat.Builder(context)
            .setSmallIcon(android.R.drawable.stat_sys_download_done)
            .setContentTitle(contentTitle)
            .setContentText(puzFile.getName())
            .setContentIntent(contentIntent)
            .setWhen(System.currentTimeMillis())
            .build();

    if (this.notificationManager != null) {
        this.notificationManager.notify(i, not);
    }
}
 
源代码4 项目: shortyz   文件: Downloaders.java
private void postDownloadedNotification(int i, String name, File puzFile) {
    try {
        String contentTitle = "Downloaded " + name;

        Intent notificationIntent = new Intent(Intent.ACTION_EDIT,
                Uri.fromFile(puzFile), context, PlayActivity.class);
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
                notificationIntent, 0);

        Notification not = new NotificationCompat.Builder(context, ShortyzApplication.PUZZLE_DOWNLOAD_CHANNEL_ID)
                .setSmallIcon(android.R.drawable.stat_sys_download_done)
                .setContentTitle(contentTitle)
                .setContentText(puzFile.getName())
                .setContentIntent(contentIntent)
                .setWhen(System.currentTimeMillis())
                .build();

        if (this.notificationManager != null) {
            this.notificationManager.notify(i, not);
        }
    } catch(Exception e){
        e.printStackTrace();
    }
}
 
源代码5 项目: OsmGo   文件: Camera.java
private void editImage(PluginCall call, Uri uri) {
  try {
    Uri origPhotoUri = uri;
    if (imageFileUri != null) {
      origPhotoUri = imageFileUri;
    }
    Intent editIntent = new Intent(Intent.ACTION_EDIT);
    editIntent.setDataAndType(origPhotoUri, "image/*");
    File editedFile = CameraUtils.createImageFile(getActivity(), false);
    Uri editedUri = Uri.fromFile(editedFile);
    editIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    editIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
    editIntent.putExtra(MediaStore.EXTRA_OUTPUT, editedUri);
    startActivityForResult(call, editIntent, REQUEST_IMAGE_EDIT);
  } catch (Exception ex) {
    call.error(IMAGE_EDIT_ERROR, ex);
  }
}
 
源代码6 项目: openlauncher   文件: ShareUtil.java
/**
 * Request edit of image (by image editor/viewer - for example to crop image)
 *
 * @param file File that should be edited
 */
public void requestPictureEdit(final File file) {
    Uri uri = getUriByFileProviderAuthority(file);
    int flags = Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION;

    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setDataAndType(uri, "image/*");
    intent.addFlags(flags);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    intent.putExtra(EXTRA_FILEPATH, file.getAbsolutePath());

    for (ResolveInfo resolveInfo : _context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)) {
        String packageName = resolveInfo.activityInfo.packageName;
        _context.grantUriPermission(packageName, uri, flags);
    }
    _context.startActivity(Intent.createChooser(intent, null));
}
 
源代码7 项目: react-native-contacts   文件: ContactsManager.java
@ReactMethod
public void openExistingContact(ReadableMap contact, Callback callback) {

    String recordID = contact.hasKey("recordID") ? contact.getString("recordID") : null;

    try {
        Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, recordID);
        Intent intent = new Intent(Intent.ACTION_EDIT);
        intent.setDataAndType(uri, ContactsContract.Contacts.CONTENT_ITEM_TYPE);
        intent.putExtra("finishActivityOnSaveCompleted", true);

        updateContactCallback = callback;
        getReactApplicationContext().startActivityForResult(intent, REQUEST_OPEN_EXISTING_CONTACT, Bundle.EMPTY);

    } catch (Exception e) {
        callback.invoke(e.toString());
    }
}
 
源代码8 项目: zom-android-matrix   文件: RouterActivity.java
Intent getEditAccountIntent() {
    Intent intent = new Intent(Intent.ACTION_EDIT, ContentUris.withAppendedId(
            Imps.Account.CONTENT_URI, mProviderCursor.getLong(ACTIVE_ACCOUNT_ID_COLUMN)));
    intent.putExtra("isSignedIn", isSignedIn(mProviderCursor));
    intent.addCategory(getProviderCategory(mProviderCursor));
    return intent;
}
 
源代码9 项目: YTPlayer   文件: RingdroidEditActivity.java
private void chooseContactForRingtone(Uri uri) {
    try {
        Intent intent = new Intent(Intent.ACTION_EDIT, uri);
        intent.setClassName(
                "com.ringdroid",
                "com.ringdroid.ChooseContactActivity");
        startActivityForResult(intent, REQUEST_CODE_CHOOSE_CONTACT);
    } catch (Exception e) {
        Log.e("Ringdroid", "Couldn't open Choose Contact window");
    }
}
 
源代码10 项目: Linphone4Android   文件: ApiElevenPlus.java
public static Intent prepareEditContactIntentWithSipAddress(int id, String sipUri) {
	Intent intent = new Intent(Intent.ACTION_EDIT, Contacts.CONTENT_URI);
	Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, id);
	intent.setData(contactUri);
	
	ArrayList<ContentValues> data = new ArrayList<ContentValues>();
	ContentValues sipAddressRow = new ContentValues();
	sipAddressRow.put(Contacts.Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE);
	sipAddressRow.put(SipAddress.SIP_ADDRESS, sipUri);
	data.add(sipAddressRow);
	intent.putParcelableArrayListExtra(Insert.DATA, data);
	
	return intent;
}
 
源代码11 项目: opentasks   文件: ViewTaskActivity.java
@Override
public void onTaskEditRequested(@NonNull Uri taskUri, ContentSet data)
{
    Intent editTaskIntent = new Intent(Intent.ACTION_EDIT);
    editTaskIntent.setData(taskUri);
    if (data != null)
    {
        Bundle extraBundle = new Bundle();
        extraBundle.putParcelable(EditTaskActivity.EXTRA_DATA_CONTENT_SET, data);
        editTaskIntent.putExtra(EditTaskActivity.EXTRA_DATA_BUNDLE, extraBundle);
    }
    startActivity(editTaskIntent);
}
 
源代码12 项目: android-apps   文件: ResultHandler.java
/**
 * Sends an intent to create a new calendar event by prepopulating the Add Event UI. Older
 * versions of the system have a bug where the event title will not be filled out.
 *
 * @param summary A description of the event
 * @param start   The start time as yyyyMMdd or yyyyMMdd'T'HHmmss or yyyyMMdd'T'HHmmss'Z'
 * @param end     The end time as yyyyMMdd or yyyyMMdd'T'HHmmss or yyyyMMdd'T'HHmmss'Z'
 * @param location a text description of the event location
 * @param description a text description of the event itself
 */
final void addCalendarEvent(String summary,
                            String start,
                            String end,
                            String location,
                            String description) {
  Intent intent = new Intent(Intent.ACTION_EDIT);
  intent.setType("vnd.android.cursor.item/event");
  long startMilliseconds = calculateMilliseconds(start);
  intent.putExtra("beginTime", startMilliseconds);
  boolean allDay = start.length() == 8;
  if (allDay) {
    intent.putExtra("allDay", true);
  }
  long endMilliseconds;
  if (end == null) {
    if (allDay) {
      // + 1 day
      endMilliseconds = startMilliseconds + 24 * 60 * 60 * 1000;
    } else {
      endMilliseconds = startMilliseconds;
    }
  } else {
    endMilliseconds = calculateMilliseconds(end);
  }
  intent.putExtra("endTime", endMilliseconds);
  intent.putExtra("title", summary);
  intent.putExtra("eventLocation", location);
  intent.putExtra("description", description);
  launchIntent(intent);
}
 
源代码13 项目: BrainPhaser   文件: UserSelectionActivity.java
/**
 * On edit a user, finish this activity and load edit user activity
 *
 * @param user To edited user
 */
@Override
public void onEditUser(User user) {
    Intent intent = new Intent(Intent.ACTION_EDIT, Uri.EMPTY, getApplicationContext(), CreateUserActivity.class);
    intent.putExtra(CreateUserActivity.KEY_USER_ID, user.getId());
    startActivityForResult(intent, 0);
}
 
源代码14 项目: opentasks   文件: TaskListFragment.java
/**
 * Opens the task editor for the selected Task.
 *
 * @param taskUri
 *         The {@link Uri} of the task.
 */
private void openTaskEditor(final Uri taskUri, final String accountType)
{
    Intent editTaskIntent = new Intent(Intent.ACTION_EDIT);
    editTaskIntent.setData(taskUri);
    editTaskIntent.putExtra(EditTaskActivity.EXTRA_DATA_ACCOUNT_TYPE, accountType);
    startActivity(editTaskIntent);
}
 
源代码15 项目: RememBirthday   文件: IntentCall.java
/**
 * Open activity for contact modifications
 */
 public static void openAppForContactModifications(Activity activity, Contact contact) {
    Intent editIntent = new Intent(Intent.ACTION_EDIT);
    editIntent.setDataAndType(contact.getUri(), ContactsContract.Contacts.CONTENT_ITEM_TYPE);
    // Response in activity
    activity.startActivityForResult(editIntent, MODIFY_CONTACT_RESULT_CODE);
}
 
源代码16 项目: Zom-Android-XMPP   文件: RouterActivity.java
Intent getEditAccountIntent() {
    Intent intent = new Intent(Intent.ACTION_EDIT, ContentUris.withAppendedId(
            Imps.Account.CONTENT_URI, mProviderCursor.getLong(ACTIVE_ACCOUNT_ID_COLUMN)));
    intent.putExtra("isSignedIn", isSignedIn(mProviderCursor));
    intent.addCategory(getProviderCategory(mProviderCursor));
    return intent;
}
 
源代码17 项目: opentasks   文件: TaskListActivity.java
@Override
public void onTaskEditRequested(@NonNull Uri taskUri, ContentSet data)
{
    Intent editTaskIntent = new Intent(Intent.ACTION_EDIT);
    editTaskIntent.setData(taskUri);
    if (data != null)
    {
        Bundle extraBundle = new Bundle();
        extraBundle.putParcelable(EditTaskActivity.EXTRA_DATA_CONTENT_SET, data);
        editTaskIntent.putExtra(EditTaskActivity.EXTRA_DATA_BUNDLE, extraBundle);
    }
    startActivity(editTaskIntent);
}
 
源代码18 项目: chuck   文件: SQLiteUtils.java
private static Intent getSQLiteDebuggerAppIntent(String path) {
    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setData(Uri.parse("sqlite:" + path));
    return intent;
}
 
源代码19 项目: Conversations   文件: ContactDetailsActivity.java
@Override
public boolean onOptionsItemSelected(final MenuItem menuItem) {
    if (MenuDoubleTabUtil.shouldIgnoreTap()) {
        return false;
    }
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setNegativeButton(getString(R.string.cancel), null);
    switch (menuItem.getItemId()) {
        case android.R.id.home:
            finish();
            break;
        case R.id.action_share_http:
            shareLink(true);
            break;
        case R.id.action_share_uri:
            shareLink(false);
            break;
        case R.id.action_delete_contact:
            builder.setTitle(getString(R.string.action_delete_contact))
                    .setMessage(JidDialog.style(this, R.string.remove_contact_text, contact.getJid().toEscapedString()))
                    .setPositiveButton(getString(R.string.delete),
                            removeFromRoster).create().show();
            break;
        case R.id.action_edit_contact:
            Uri systemAccount = contact.getSystemAccount();
            if (systemAccount == null) {
                quickEdit(contact.getServerName(), R.string.contact_name, value -> {
                    contact.setServerName(value);
                    ContactDetailsActivity.this.xmppConnectionService.pushContactToServer(contact);
                    populateView();
                    return null;
                }, true);
            } else {
                Intent intent = new Intent(Intent.ACTION_EDIT);
                intent.setDataAndType(systemAccount, Contacts.CONTENT_ITEM_TYPE);
                intent.putExtra("finishActivityOnSaveCompleted", true);
                try {
                    startActivity(intent);
                } catch (ActivityNotFoundException e) {
                    Toast.makeText(ContactDetailsActivity.this, R.string.no_application_found_to_view_contact, Toast.LENGTH_SHORT).show();
                }

            }
            break;
        case R.id.action_block:
            BlockContactDialog.show(this, contact);
            break;
        case R.id.action_unblock:
            BlockContactDialog.show(this, contact);
            break;
    }
    return super.onOptionsItemSelected(menuItem);
}
 
源代码20 项目: shortyz   文件: HttpDownloadActivity.java
private void initializeDownload() {
    if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
        showSDCardHelp();
        finish();

        return;
    }

    Uri u = this.getIntent()
                .getData();
    String filename = u.toString();
    filename = filename.substring(filename.lastIndexOf('/') + 1);

    final ProgressDialog dialog = new ProgressDialog(this);
    dialog.setMessage("Downloading...\n" + filename);
    dialog.setCancelable(false);

    OkHttpClient client = new OkHttpClient();

    try {
        Request request = new Request.Builder()
                .url(u.toString())
                .build();

        Response response = client.newCall(request).execute();

        if (response.code() != 200) {
            throw new IOException("Non 200 downloading...");
        }

        InputStream is = response.body().byteStream();
        File puzFile = new File(crosswordsFolder, filename);
        FileOutputStream fos = new FileOutputStream(puzFile);
        copyStream(is, fos);
        fos.close();

        Intent i = new Intent(Intent.ACTION_EDIT, Uri.fromFile(puzFile), this, PlayActivity.class);
        this.startActivity(i);
    } catch (Exception e) {
        e.printStackTrace();

        Toast t = Toast.makeText(this, "Unable to download from\n" + u.toString(), Toast.LENGTH_LONG);
        t.show();
    }

    finish();
}
 
 方法所在类
 同类方法