Created
September 1, 2012 08:37
-
-
Save grsahil20/3567333 to your computer and use it in GitHub Desktop.
Setting a Android walpaper using Titanium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Titanium.UI.setBackgroundColor('#000'); | |
var win = Titanium.UI.createWindow({ | |
title : 'Test', | |
backgroundColor : '#000', | |
fullscreen : false, | |
exitOnClose : true | |
}); | |
var cb = function(data) { | |
var blob = data.media; | |
Ti.API.info(blob); | |
Ti.Media.Android.setSystemWallpaper(blob, true); | |
}; | |
var err = function(e) { | |
Ti.API.error(e); | |
}; | |
var cancel = function() { | |
Ti.API.warn('Cancelled'); | |
}; | |
var btn = Ti.UI.createButton({ | |
title : 'Camera', | |
top : 0, | |
height : "40dp", | |
left : 0, | |
right : 0 | |
}); | |
win.add(btn); | |
btn.addEventListener('click', function() { | |
Ti.Media.showCamera({ | |
success : cb, | |
error : err, | |
cancel : cancel | |
}); | |
}); | |
var gallery = Ti.UI.createButton({ | |
title : 'Gallery', | |
top : "45dp", | |
height : "40dp", | |
left : 0, | |
right : 0 | |
}); | |
gallery.addEventListener('click', function() { | |
Ti.Media.openPhotoGallery({ | |
success : cb, | |
error : err, | |
cancel : cancel | |
}); | |
}); | |
win.add(gallery); | |
var file = Ti.UI.createButton({ | |
title : 'File', | |
top : "90dp", | |
height : "40dp", | |
left : 0, | |
right : 0 | |
}); | |
file.addEventListener('click', function() { | |
var f = Ti.Filesystem.getFile('KS_nav_ui.png'); | |
var blob = f.read(); | |
Ti.Media.Android.setSystemWallpaper(blob, true); | |
}); | |
win.add(file); | |
win.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment