如何设置Android的壁纸? [英] How to set Android wallpaper?

查看:395
本文介绍了如何设置Android的壁纸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我如何编程在Delphi XE5-8设置壁纸的Andr​​oid桌面上?的结果
谢谢你。


解决方案

由@LURD和@FreeConsulting链接复制

下面是一个方法来设置wallpaper.don't知道它是多么正确或错误)。

动态壁纸是不是太大的不同,所以这是一个起点。


  

      
  1. 使用Java2op生成所有壁纸类的德尔福桥文件。


  2.   
  3. 新FMX poject


  4.   
  5. 单位添加到您的使用条款沿:


  6.   
  7. 在窗体上放置如下:
      Button1的:TButton的;
      此搜索:TImageViewer;


  8.   
  9. 加载图像Image1的进入在设计时间。并设置Button1的的onclick以下。


  10.   

code:

 程序TForm1.Button1Click(发件人:TObject的);
瓦尔
  FWallpaperManager:JWallpaperManager;
  Factoryoptions:JBitmapFactory_Options;
  AScreenSize:TPoint;
  WidthOfScreen,HeightOfScreen:整数;
  FFileToOpen:字符串;
开始
  {创建一个文件名图像保存到}
  FFiletoopen:= System.IOUtils.TPath.Combine(System.IOUtils.TPath.GetDocumentsPath,'Thefile.jpg');
  {保存图像}
  Image1.Bitmap.SaveToFile(FFileToOpen);
  {创建JBitmap选项}
  Factoryoptions:= TJBitmapFactory_Options.Create;
  {阅读上这些在Android API中}
  Factoryoptions.inJustDe codeBounds:= TRUE;
  Factoryoptions.in preferQualityOverSpeed​​:= TRUE;
  Factoryoptions.inJustDe codeBounds:= FALSE;
  {获取壁纸管理器实例}
  FWallpaperManager:= TJWallpaperManager.Wrap((SharedActivityContext.GetSystemService
               (TJContext.JavaClass.WALLPAPER_SERVICE)为ILocalObject).GetObjectID);
  {载入我们保存的图像}
  TheBitmaptoShow:= TJBitmapfactory.JavaClass.De codeFILE(StringToJString(FFiletoopen),FactoryOptions);
  {只有改变,如果该位图负荷壁纸}
  如果TheBitmaptoShow<>零然后开始
    {设置壁纸}
    FWallpaperManager.SetBitmap(TheBitmaptoShow);
  结束;
结束;

Can anyone tell me how to programmatically set the Wallpaper on Android desktop in Delphi XE5-8?
Thanks.

解决方案

Copy of the link by @LURD and @FreeConsulting

Here's a way to Set the wallpaper.don't know how right or wrong it is).

Live wallpaper is not to much different, so this is a starting point

  1. Use Java2op to generate the delphi bridge files of all the wallpaper classes.

  2. New Fmx poject

  3. Add the units to your uses clause along with:

  4. place the following on the form: Button1: TButton; Image1: TImageViewer;

  5. Load an image into Image1 in design time. and set Button1 onclick to below.

Code:

procedure TForm1.Button1Click(Sender: TObject);
Var
  FWallpaperManager: JWallpaperManager;
  Factoryoptions: JBitmapFactory_Options;
  AScreenSize: TPoint;
  WidthOfScreen, HeightOfScreen: Integer;
  FFileToOpen: string;
begin
  {Create a filename to save the image to}
  FFiletoopen:= System.IOUtils.TPath.Combine(System.IOUtils.TPath.GetDocumentsPath, 'Thefile.jpg');
  {Save the image}
  Image1.Bitmap.SaveToFile(FFileToOpen);
  {Create JBitmap options }
  Factoryoptions:= TJBitmapFactory_Options.Create;
  {Read up on these in the android API}
  Factoryoptions.inJustDecodeBounds:= True;
  Factoryoptions.inPreferQualityOverSpeed:= True;
  Factoryoptions.inJustDecodeBounds:= False;
  {Get the wallpaper manager instance}
  FWallpaperManager:= TJWallpaperManager.Wrap((SharedActivityContext.GetSystemService
               (TJContext.JavaClass.WALLPAPER_SERVICE) as  ILocalObject).GetObjectID);
  {Load the image we saved}
  TheBitmaptoShow:= TJBitmapfactory.JavaClass.DecodeFile(StringToJString(FFiletoopen), FactoryOptions);
  {Only change the wallpaper if the Bitmap loads}
  if TheBitmaptoShow <> nil then begin
    {Set the Wallpaper}
    FWallpaperManager.SetBitmap(TheBitmaptoShow);        
  end;
end;

这篇关于如何设置Android的壁纸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆