Android Intents PART-2

15:57:00 Dhaval Sodha Parmar 0 Comments

1. Launching the Music Player

 Intent myActivity2 = new Intent("android.intent.action.MUSIC_PLAYER");  
 startActivity(myActivity2);  

2. Playing a song stored in the SD card

 Intent myActivity2 = new Intent(android.content.Intent.ACTION_VIEW);  
 Uri data = Uri.parse("file:///sdcard/test.mp3");  
 String type = "audio/mp3";  
 myActivity2.setDataAndType(data, type);  
 startActivity(myActivity2);  

3. Sending MMS
 Uri uri = Uri.parse("content://media/external/images/media/1");  
 Intent i = new Intent(Intent.ACTION_SEND);  
 i.putExtra("address", "555-1234");  
 i.putExtra("sms_body", "some text message");  
 i.putExtra(Intent.EXTRA_STREAM, uri);  
 i.setType("image/png");  
 startActivity(i);  

4. Sending Email
 Uri uri = Uri.parse("mailto:dhaval0122@gmail.com");  
 Intent myActivity2 = new Intent(Intent.ACTION_SENDTO, uri);  
 myActivity2.putExtra(Intent.EXTRA_SUBJECT, "subject goes here");  
 myActivity2.putExtra(Intent.EXTRA_TEXT,"The email's body goes here");  
 startActivity(myActivity2);  

5. Setting System
 Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);  
 startActivity(intent);  


6. Setting System Locale: Language & Keyboard

 Intent intent = new Intent(android.provider.Settings.ACTION_LOCALE_SETTINGS);  
 startActivity(intent);  

0 comments: