Android ClipDescription - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ClipDescription class.

This code example shows how to use the following methods:filterMimeTypes
                return null; 
 
            // If the pattern is for note IDs and the MIME filter is text/plain, then return 
            // text/plain 
            case NOTE_ID:
                return NOTE_STREAM_TYPES.filterMimeTypes(mimeTypeFilter);
 
                // If the URI pattern doesn't match any permitted patterns, throws an exception. 
            default: 
                throw new IllegalArgumentException("Unknown URI " + uri);
            } 
    } 
 
 
    /** 
     * Returns a stream of data for each supported stream type. This method does a query on the 
     * incoming URI, then uses 
     * {@link android.content.ContentProvider#openPipeHelper(Uri, String, Bundle, Object, 
     * PipeDataWriter)} to start another thread in which to convert the data into a stream. 
     * 
5
CodeRank
This code example shows how to use the following methods:filterMimeTypes
                return null; 
 
            // If the pattern is for note IDs and the MIME filter is text/plain, then return 
            // text/plain 
            case NOTE_ID:
                return NOTE_STREAM_TYPES.filterMimeTypes(mimeTypeFilter);
 
                // If the URI pattern doesn't match any permitted patterns, throws an exception. 
            default: 
                throw new IllegalArgumentException("Unknown URI " + uri);
            } 
    } 
 
 
    /** 
     * Returns a stream of data for each supported stream type. This method does a query on the 
     * incoming URI, then uses 
     * {@link android.content.ContentProvider#openPipeHelper(Uri, String, Bundle, Object, 
     * PipeDataWriter)} to start another thread in which to convert the data into a stream. 
     * 
3
CodeRank
This code example shows how to use the following methods:hasMimeType
	boolean processDragStarted(DragEvent event) {
		// Determine whether to continue processing drag and drop based on the 
		// plain text mime type. 
		final ClipDescription clipDesc = event.getClipDescription();
		if (clipDesc != null)
			return clipDesc.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
		return false; 
	} 
 
	boolean processDrop(DragEvent event, ImageView imageView) {
		// Attempt to parse clip data with expected format: category||entry_id. 
		// Ignore event if data does not conform to this format. 
		final ClipData data = event.getClipData();
		if (data != null) {
			if (data.getItemCount() > 0) {
				final Item item = data.getItemAt(0);
				final String textData = (String) item.getText();
				if (textData != null) {
					final StringTokenizer tokenizer = new StringTokenizer(
							textData, "||");
4
CodeRank
This code example shows how to use the following methods:hasMimeType
    boolean processDragStarted(DragEvent event) {
        // Determine whether to continue processing drag and drop based on the 
        // plain text mime type. 
        ClipDescription clipDesc = event.getClipDescription();
        if (clipDesc != null) {
            return clipDesc.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
        } 
        return false; 
    } 
 
    boolean processDrop(DragEvent event, ImageView imageView) {
        // Attempt to parse clip data with expected format: category||entry_id. 
        // Ignore event if data does not conform to this format. 
        ClipData data = event.getClipData();
        if (data != null) {
            if (data.getItemCount() > 0) {
                Item item = data.getItemAt(0);
                String textData = (String) item.getText();
                if (textData != null) {
                    StringTokenizer tokenizer = new StringTokenizer(textData, "||");
3
CodeRank
This code example shows how to use the following methods:
        //MIMETYPEの作成 
        String[] mimeType = new String[1];
        mimeType[0] = ClipDescription.MIMETYPE_TEXT_PLAIN;
 
        //クリップボードに格納するClipDataオブジェクトの作成 
        ClipData cd = new ClipData(new ClipDescription("text_data", mimeType), item);
 
        //クリップボードにデータを格納 
        cm.setPrimaryClip(cd);
    } 
} 
4
CodeRank
This code example shows how to use the following methods:
	 */ 
	@SuppressLint("NewApi") 
	private static void addItemToClipboard (final Context context, final String label, final String value) {
		ClipboardManager manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
		ClipData.Item item = new Item(value);
		ClipDescription description = new ClipDescription(label, new String [] {ClipDescription.MIMETYPE_TEXT_PLAIN});
		ClipData data = new ClipData(description, item);
		manager.setPrimaryClip(data);				
	} 
 
	/** 
	 * This is only called when oldAPi is passed as true on {@link #addItemToClipboard(Context, String, String, boolean)} 
	 * @param context The context, required to get the Cliboard System Service.  
	 * @param value The value to store on the clipboard.  
	 */ 
	@SuppressWarnings("deprecation") 
	private static void addTextToClipboard (final Context context, final String value) {
		android.text.ClipboardManager manager = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
		manager.setText(value);			
	} 
3
CodeRank
This code example shows how to use the following methods:filterMimeTypes
                return null; 
 
            // If the pattern is for note IDs and the MIME filter is text/plain, then return 
            // text/plain 
            case NOTE_ID:
                return NOTE_STREAM_TYPES.filterMimeTypes(mimeTypeFilter);
 
            // If the URI pattern doesn't match any permitted patterns, throws an exception. 
            default: 
                throw new IllegalArgumentException("Unknown URI " + uri);
        } 
    } 
 
 
    /** 
     * Returns a stream of data for each supported stream type. This method does a query on the 
     * incoming URI, then uses 
     * {@link android.content.ContentProvider#openPipeHelper(Uri, String, Bundle, Object, 
     * PipeDataWriter)} to start another thread in which to convert the data into a stream. 
     * 
3
CodeRank
This code example shows how to use the following methods:hasMimeType
	boolean processDragStarted(DragEvent event) {
		// Determine whether to continue processing drag and drop based on the 
		// plain text mime type. 
		final ClipDescription clipDesc = event.getClipDescription();
		if (clipDesc != null)
			return clipDesc.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
		return false; 
	} 
 
	boolean processDrop(DragEvent event, ImageView imageView) {
		// Attempt to parse clip data with expected format: category||entry_id. 
		// Ignore event if data does not conform to this format. 
		final ClipData data = event.getClipData();
		if (data != null) {
			if (data.getItemCount() > 0) {
				final Item item = data.getItemAt(0);
				final String textData = (String) item.getText();
				if (textData != null) {
					final StringTokenizer tokenizer = new StringTokenizer(
							textData, "||");
4
CodeRank
This code example shows how to use the following methods:filterMimeTypes
                return null; 
 
            // If the pattern is for task IDs and the MIME filter is text/plain, then return 
            // text/plain 
            case TASK_ID:
                return TASK_STREAM_TYPES.filterMimeTypes(mimeTypeFilter);
 
            // If the URI pattern doesn't match any permitted patterns, throws an exception. 
            default: 
                throw new IllegalArgumentException("Unknown URI " + uri);
        } 
    } 
 
 
    /** 
     * Returns a stream of data for each supported stream type. This method does a query on the 
     * incoming URI, then uses 
     * {@link android.content.ContentProvider#openPipeHelper(Uri, String, Bundle, Object, 
     * PipeDataWriter)} to start another thread in which to convert the data into a stream. 
     * 
3
CodeRank
This code example shows how to use the following methods:filterMimeTypes
            case WIDGET:
            case LIVE_FOLDER_WIDGET:
                return null; 
 
            case WIDGET_ID:
                return NOTE_STREAM_TYPES.filterMimeTypes(mimeTypeFilter);
 
            default: 
                throw new IllegalArgumentException("Unknown URI " + uri);
            } 
    } 
 
 
    @Override 
    public AssetFileDescriptor openTypedAssetFile(Uri uri, String mimeTypeFilter, Bundle opts)
            throws FileNotFoundException { 
 
        String[] mimeTypes = getStreamTypes(uri, mimeTypeFilter);
 
        if (mimeTypes != null) {
3
CodeRank
See Code Examples for Android ClipDescription Methods: