I am developing an iphone app where i have to change lockscreen image programmatically when app is running in background.I have got lots of stuff saying it is not possible b
there is No way to do this effect unless a app runs in a jailbreak iDevice ( and it means the app can't be submitted to App Store).
The only way you can change the lockscreen image is when you are playing audio. Police Scanner+ does play audio, and therefore can set an image. This only works with iOS 5+ and is done something like this.
- (void)setupNowPlayingInfoCenter:(MPMediaItem *)currentSong
{
NSString *ver = [[UIDevice currentDevice] systemVersion];
CGFloat version = 4.0;
if ([ver length] >= 3)
{
version = [[ver substringToIndex:3] floatValue];
}
if (version >= 5.0)
{
MPMediaItemArtwork *artwork = [currentSong valueForProperty:MPMediaItemPropertyArtwork];
MPNowPlayingInfoCenter *infoCenter = [MPNowPlayingInfoCenter defaultCenter];
if (currentSong == nil)
{
infoCenter.nowPlayingInfo = nil;
return;
}
infoCenter.nowPlayingInfo = [NSDictionary dictionaryWithObjectsAndKeys:
[currentSong valueForKey:MPMediaItemPropertyTitle], MPMediaItemPropertyTitle,
[currentSong valueForKey:MPMediaItemPropertyArtist], MPMediaItemPropertyArtist,
[currentSong valueForKey:MPMediaItemPropertyAlbumTitle], MPMediaItemPropertyAlbumTitle,
[currentSong valueForKey:MPMediaItemPropertyAlbumTrackCount], MPMediaItemPropertyAlbumTrackCount,
[currentSong valueForKey:MPMediaItemPropertyAlbumTrackNumber], MPMediaItemPropertyAlbumTrackNumber,
artwork, MPMediaItemPropertyArtwork,
[currentSong valueForKey:MPMediaItemPropertyComposer], MPMediaItemPropertyComposer,
[currentSong valueForKey:MPMediaItemPropertyDiscCount], MPMediaItemPropertyDiscCount,
[currentSong valueForKey:MPMediaItemPropertyDiscNumber], MPMediaItemPropertyDiscNumber,
[currentSong valueForKey:MPMediaItemPropertyGenre], MPMediaItemPropertyGenre,
[currentSong valueForKey:MPMediaItemPropertyPersistentID], MPMediaItemPropertyPersistentID,
[currentSong valueForKey:MPMediaItemPropertyPlaybackDuration], MPMediaItemPropertyPlaybackDuration,
[NSNumber numberWithInt:self.mediaCollection.nowPlayingIndex + 1], MPNowPlayingInfoPropertyPlaybackQueueIndex,
[NSNumber numberWithInt:[self.mediaCollection count]], MPNowPlayingInfoPropertyPlaybackQueueCount, nil];
}
}