Code example for Intent

Methods: putExtra, getLongExtra

0
        assertSame(parcels, intent.getExtras().getParcelableArrayList("foo"));
    } 
 
    @Test 
    public void testLongExtra() throws Exception { 
        Intent intent = new Intent();
        assertSame(intent, intent.putExtra("foo", 2L));
        assertEquals(2L, shadowOf(intent).getExtras().get("foo"));
        assertEquals(2L, intent.getLongExtra("foo", -1));
        assertEquals(-1L, intent.getLongExtra("bar", -1));
    } 
     
    @Test 
    public void testBundleExtra() throws Exception { 
        Intent intent = new Intent();
        Bundle bundle = new Bundle();
        bundle.putInt("bar", 5);
        assertSame(intent, intent.putExtra("foo", bundle));
        assertEquals(5, intent.getBundleExtra("foo").getInt("bar"));
    }