Android FormatException - 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 FormatException class.

This code example shows how to use the following methods:
        if (tnf == NdefRecord.TNF_WELL_KNOWN &&
                Arrays.equals(NdefRecord.RTD_URI, record.getType())) {
            byte[] payload = record.getPayload();
            int pre = (int)payload[0];
            if (!(pre >= 0 && pre < URI_PREFIXES.length)) {
                throw new FormatException("Unknown uri prefix: " + pre);
            } 
            String prefix = URI_PREFIXES[pre];
            String uriStr = new StringBuilder()
                .append(prefix).append(new String(payload, 1, payload.length - 1))
                .toString();
            return Uri.parse(uriStr);
        } 
        throw new FormatException("NdefRecord is not a uri.");
    } 
 
    /** 
     * Converts an Ndef message to its uri encoding, using the 
     * {code ndef://} scheme. 
     */ 
5
CodeRank
This code example shows how to use the following methods:printStackTrace
			} catch (IOException e) {
				Log.e("TAG", "Impossible de se connecter au p�riph�rique NFC");
				e.printStackTrace();
			} catch (FormatException e) {
				Log.e("TAG", "Impossible de formatter");
				e.printStackTrace();
			} catch (Exception e) {
				Log.e("TAG", "Le message est trop long pour ce p�riph�rique.");
				e.printStackTrace();
			} 
		} 
	} 
	 
	 
	private void displayMessage(String message) {
		mTextView.setText(message+"\n");
	} 
	 
	private void addMessage(String message){
		mTextView.append(message+"\n");
3
CodeRank
This code example shows how to use the following methods:printStackTrace
			// TODO Auto-generated catch block 
			e.printStackTrace();
			return false ; 
		} catch (FormatException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
			return false ; 
		} 
		 
		try { 
			ndefTag.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
			return false ; 
		} 
				 
		return true ; 
	} 
} 
3
CodeRank
This code example shows how to use the following methods:printStackTrace
			// TODO Auto-generated catch block 
			e.printStackTrace();
			return false ; 
		} catch (FormatException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
			return false ; 
		} 
		 
		try { 
			ndefTag.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
			return false ; 
		} 
				 
		return true ; 
	} 
} 
3
CodeRank
This code example shows how to use the following methods:printStackTrace
        } catch (IOException e) {
            tellTheUserProgrammingFailed(e);                
            e.printStackTrace();
        } catch (FormatException e) {
            tellTheUserProgrammingFailed(e);                
            e.printStackTrace();
        } finally { 
            close(ndefTag);
        } 
    } 
 
    private void tellTheUserTheTagWasProgrammed() { 
        Toast.makeText(this, "Tag successfully programmed", Toast.LENGTH_LONG).show();
    } 
 
    private void tellTheUserProgrammingFailed(Exception e) {
        Toast.makeText(this, "Failed to program tag: " + e.getMessage(), Toast.LENGTH_LONG).show();
    } 
 
    private void tellTheUserTagIsNotWritable() { 
4
CodeRank
This code example shows how to use the following methods:printStackTrace
            try { 
                writeTag(tag, numberString);
            } catch (IOException e) {
                e.printStackTrace();
            } catch (FormatException e) {
                e.printStackTrace();
            } 
        } 
    } 
 
    protected boolean writeTag(Tag tag, String nfcMessage) throws IOException , FormatException{
        //Record to launch Play Store if not installed 
        NdefRecord appRecord = NdefRecord.createApplicationRecord(this.getPackageName());
 
        // Record with actual data we care about 
        byte[] payload = nfcMessage.getBytes();
        byte[] mimeBytes = MimeType.NFC_DEMO.getBytes(Charset.forName("US-ASCII"));
        NdefRecord cardRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, mimeBytes,
                new byte[0], payload);
        // Complete NDEF message with both records 
4
CodeRank
This code example shows how to use the following methods:printStackTrace
 
		// Create an NDEF message with some sample text 
		try { 
			ndefMessage = new NdefMessage(uriRecord.toByteArray());
		} catch (FormatException e) {
			e.printStackTrace();
		} 
		return ndefMessage;
	} 
	//	 
	//	public void onCreate(Bundle savedInstanceState) { 
	//		super.onCreate(savedInstanceState); 
	//		setContentView(R.layout.contagious); 
	//		String data = "TEST NDEF!"; 
	//		ndefMessage = new NdefMessage(new NdefRecord[]{ 
	//				NdefRecord.createUri(data) 
	//		}); 
	//		NfcAdapter.getDefaultAdapter(this).setNdefPushMessage(msg, this); 
	//		 
	//		// NfcAdapter adapter = manager.getDefaultAdapter(); 
4
CodeRank
This code example shows how to use the following methods:printStackTrace
						new Contact("Chiara", "Fiaschetti", 3334047755L, "chiara.mcf86@gmail.com"), 
						new Contact("Marco", "De Cristofaro", 3292788296L, "marco.decristofaro@gmail.com"), 
						new Contact("Giulia", "Fiaschetti", 3491665809L, "giulia.fiaschetti@gmail.com"), 
				}); 
			} catch (FormatException e) {
				e.printStackTrace();
			} 
	        multichoiceDialogFragment.show(fm, "fragment_edit_name");
		} 
		 
	} 
 
	 
	/* (non-Javadoc) 
	 * @see com.example.androidexamples.dialog_fragment.MultichoiceDialogFragment.onMultichoiceDialogFragmentListener#onChoice(com.example.androidexamples.fragment_example.support.Contact[]) 
	 */ 
	@Override 
	public void onChoice(Contact[] contacts) {
		if(contacts==null || contacts.length==0) {
			Toast.makeText(this, R.string.noItemSelected, Toast.LENGTH_LONG).show();
4
CodeRank
This code example shows how to use the following methods:printStackTrace
						new Contact("Chiara", "Fiaschetti", 3334047755L, "chiara.mcf86@gmail.com"), 
						new Contact("Marco", "De Cristofaro", 3292788296L, "marco.decristofaro@gmail.com"), 
						new Contact("Giulia", "Fiaschetti", 3491665809L, "giulia.fiaschetti@gmail.com"), 
				}); 
			} catch (FormatException e) {
				e.printStackTrace();
			} 
	        multichoiceDialogFragment.show(fm, "fragment_edit_name");
		} 
		 
	} 
 
	 
	/* (non-Javadoc) 
	 * @see com.example.androidexamples.dialog_fragment.MultichoiceDialogFragment.onMultichoiceDialogFragmentListener#onChoice(com.example.androidexamples.fragment_example.support.Contact[]) 
	 */ 
	@Override 
	public void onChoice(Contact[] contacts) {
		if(contacts==null || contacts.length==0) {
			Toast.makeText(this, R.string.noItemSelected, Toast.LENGTH_LONG).show();
4
CodeRank
This code example shows how to use the following methods:printStackTrace
        try { 
            nmessage = ndef.getNdefMessage();
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (FormatException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } 
        //do something with tagFromIntent 
    } 
 
    public void onResume() 
    { 
        super.onResume(); 
        nfc = new Nfc();
        mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
 
        if (mNfcAdapter == null) {
            Toast.makeText(this, "NFC is not available", Toast.LENGTH_LONG).show();
            finish();
            return; 
4
CodeRank

Related Android FormatException Questions & Answers:

See Code Examples for Android FormatException Methods: