19
CONTENT PROVIDERS

Level 3

Embed Size (px)

Citation preview

Page 1: Level 3

CONTENT PROVIDERS

Page 2: Level 3

CONFIDENTIAL INFORMATIONThis document is confidential and proprietary information of Target Soft Systems. Confidential Information includes, but is not limited to, the following: Corporate, Employee and Infrastructure Information about Target Soft Systems.

Target Soft Systems implementation , Training methodology, cost, project management and quality processes. Any disclosure of Confidential Information to, or use of it by a third party (i.e., a party other than authorised , will be damaging to Target Soft Systems). Ownership of all Confidential Information, no matter in what media it resides, remains with Target Soft Systems( TSS ). Confidential Information in this document shall not be disclosed outside the buyer’s proposal evaluators and shall not be duplicated, used, or disclosed – in whole or in part – for any purpose other than to evaluate this proposal without specific written permission of an authorized representative of Target Soft Systems.

Page 3: Level 3

• * If you want to share data with other applications you can use a ContentProvider.

• * A ContentProvider allows applications to access data.

• * The access to a ContentProvider is done via an URI (Uniform Resource Identifier). The basis for the URI is defined in the declaration of the ContentProvider in the AndroidManifest.xml file via the android:authorities attribute.

• * Many Android data sources, e.g. the contacts, are accessible via ContentProviders. Typically the implementing classes for a ContentProviders provide public constants for the URIs.

Page 4: Level 3

Some of the useful Content Providers are, Browser – Stores data such as browser bookmarks, history CallLog – Stores data such as missed calls, call details. Contacts – Stores Contact Details MediaStore – Stores media files such as audio, video and

images Settings – Stores the settings of the device and preferences. Format of the query string URI (Uniform Resource Identifier)

<Standard Prefix >://<authority>/<data_path>/<id>

Page 5: Level 3
Page 6: Level 3

public final Cursor managedQuery (Uri uri, String[] projection, String selection, String[]   selectionArgs, String sortOrder) Parameters:uri --The URI of the content provider to query.projection --List of columns to return.selection --SQL WHERE clause.selectionArgs --The arguments to selection, if any ?s are presentsortOrder --SQL ORDER BY clause. Returns:The Cursor returned by query ().

Page 7: Level 3

import android.provider.CallLog;import android.database.Cursor; // Form an array specifying the columns to return.String[] callLogColumnList = new String[] {               CallLog.Calls.NUMBER, CallLog.Calls.CACHED_NAME,             CallLog.Calls.DATE, CallLog.Calls.DURATION,             CallLog.Calls.TYPE }; // Get the base URI for the People table in the Contacts content provider.Uri callLogs = CallLog.Calls.CONTENT_URI;Uri callLogs = Uri.parse(“content://call_logs/calls”); 

Page 8: Level 3

// Make the query.Cursor managedCursor = managedQuery (callLogs,        callLogColumnList, // which columns to return        null, // Which rows to return (all rows) null,       // Selection arguments (none)        CallLog.Calls.DATE + "DESC" //results in descending order by date);

Page 9: Level 3

MULTIMEDIA

Page 10: Level 3

Media PlayerMediaPlayer class can be used to control playback of

audio/video files and streams. Playback control of audio/video files and streams is managed as a state machine.

• publicstatic MediaPlayer create (Context context, Uri uri, SurfaceHolderholder)

• Added in API level 1

• Convenience method to create a MediaPlayer for a given Uri. On success, prepare() will already have been called and must not be called again.

Page 11: Level 3

When done with the MediaPlayer, you should call release(), to free the resources. If not released, too many MediaPlayer instances will result in an exception.

Parameters

Context the Context to use uri the Uri from which to get the data source holder the SurfaceHolder to use for displaying the video

Returns

a MediaPlayer object, or null if creation failed

Page 12: Level 3

ACTIVITY LIFE CYCLEACTIVITY LIFE CYCLE onCreate( ) onStart( ) onPause( ) onResume( )

onStop( ) onRestart( )onDestroy( )

Page 13: Level 3

ACTIVITY LIFE CYCLEACTIVITY LIFE CYCLEFLOW DIAGRAMFLOW DIAGRAM

Page 14: Level 3
Page 15: Level 3

Supported Media Formats

Audio Format :

3GPP (.3gp)

MPEG-4 (.mp4, .m4a)

ADTS raw AAC (.aac, decode in Android 3.1+, encode in

Android 4.0+, ADIF not supported)

MP3 (.mp3)

WAVE (.wav)

Page 16: Level 3

MediaPlayer mp = new MediaPlayer();// Set data source -setDataSource("/sdcard/path_to_song");// Play audiomp.start();// Pause audiomp.pause();// Reset mediaplayermp.reset();// Get song length duration - in millisecondsmp.getDuration();// Get current duration - in millisecondsmp.getCurrentDuration();// Move song to particular second - used for Forward or Backwardmp.seekTo(positon); // position in milliseconds// Check if song is playing or notmp.isPlaying(); // returns true or false

Audio Player

Page 17: Level 3

Video Format :

3GPP (.3gp)MPEG-4 (.mp4)WebM (.webm)Matroska (.mkv, Android 4.0+)Image Format :

JPEG (.jpg)GIF (.gif)PNG (.png)BMP (.bmp)

Supported Media Formats

Page 18: Level 3

VideoView videoView =(VideoView)findViewById(R.id.videoView);MediaController mediaController= new MediaController(this);mediaController.setAnchorView(videoView); Uri uri=Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.one); videoView.setMediaController(mediaController); videoView.setVideoURI(uri); videoView.requestFocus(); videoView.start(); videoView.stopPlayback();videoView.pause();videoView.isPlaying(); videoView.getDuration();videoView.getCurrentPosition();

Video Player

Page 19: Level 3

THANK YOU