Code example for Intent

Methods: getExtrasputExtra, getFloatExtra

0
        assertEquals(2d, intent.getDoubleExtra("foo", -1));
    } 
 
    @Test 
    public void testFloatExtra() throws Exception { 
        Intent intent = new Intent();
        assertSame(intent, intent.putExtra("foo", 2f));
        assertEquals(2f, intent.getExtras().get("foo"));
        assertEquals(2f, intent.getFloatExtra("foo", -1));
    } 
 
    @Test 
    public void testIntArrayExtra() throws Exception { 
        Intent intent = new Intent();
        int[] array = new int[2];
        array[0] = 1;
        array[1] = 2;
        assertSame(intent, intent.putExtra("foo", array));
        assertEquals(1, intent.getIntArrayExtra("foo")[0]);
        assertEquals(2, intent.getIntArrayExtra("foo")[1]);
    }