相关资料:

1.群号383675978

2.http://blog.sina.com.cn/s/blog_44fa172f0101rmjt.html

3.PS:ListView1.ItemAppearanceObjects.ItemObjects.Text.Font.Size:=20; 设置字体大小,属性面板也可以设置。代码设置时需要看一下手机支持的大小是多少。

实例源码:

 unit Unit1;

 interface

 uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Controls.Presentation, FMX.Edit,
Androidapi.JNI.JavaTypes,//JString使用
Androidapi.JNI.GraphicsContentViewText,//JIntent使用
FMX.Surfaces,//TBitmapSurface使用
Androidapi.Helpers,//SharedActivity使用
System.IOUtils,//TPath使用
Androidapi.JNIBridge,//ILocalObject使用
FMX.Helpers.Android,//JBitmapToSurface使用
System.Generics.Collections,//TList使用
FMX.ListView.Types, FMX.ListView.Appearances,
FMX.ListView.Adapters.Base, FMX.ListView, FMX.StdCtrls, FMX.ScrollBox,
FMX.Memo; type
TForm1 = class(TForm)
Edit1: TEdit;
ListView1: TListView;
Button1: TButton;
Memo1: TMemo;
procedure Edit1Change(Sender: TObject);
procedure Edit1Typing(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ListView1ItemClick(const Sender: TObject;
const AItem: TListViewItem);
private
{ Private declarations }
MainList : TList<JActivityInfo>;
dictAppIcons : TDictionary<Integer, TBitmap>;
//过虑方法
procedure FilterListView(AListView: TListView; AFilterName: string);
//打开APP方法
procedure OpenApp(PackageName, AppName : JString);
//获取安装的APP
function GetActivityAppList: JList;
function GetOrSetCashAppIcon(appInfo: JApplicationInfo): TBitmap;
procedure LoadActivityInfoList(var List: TList<JActivityInfo>);
procedure LoadDictonaryAppIcons(index: Integer; appInfo: JApplicationInfo;
var dictonaryAppIcons: TDictionary<Integer, TBitmap>);
procedure LoadListView(listView: TListView; AppList: TList<JActivityInfo>;
dictonaryAppIcons: TDictionary<Integer, TBitmap>);
procedure LoadListViewBitmap(listView: TListView; AppList: TList<JActivityInfo>;
var dictonaryAppIcons: TDictionary<Integer, TBitmap>);
public
{ Public declarations }
end; const
DEFAUT_INDEX: Integer = -; var
Form1: TForm1; implementation {$R *.fmx}
{$R *.NmXhdpiPh.fmx ANDROID} { TForm1 }
//调用打开APP
procedure TForm1.Button1Click(Sender: TObject);
begin
OpenApp(StringToJString('com.androidillusion.videocamillusionpro'),
StringToJString('com.androidillusion.videocamillusionpro.VideoillusionActivity'));
end; //改变事件
procedure TForm1.Edit1Change(Sender: TObject);
begin
if Edit1.Text = '' then
FilterListView(Self.ListView1, Edit1.Text.Trim);
end; //输入事件
procedure TForm1.Edit1Typing(Sender: TObject);
begin
FilterListView(Self.ListView1, Edit1.Text.Trim);
end; //过虑方法
procedure TForm1.FilterListView(AListView: TListView; AFilterName: string);
var
i: integer;
item: TListViewItem;
lower: string;
begin
if not Assigned(AListView) then
Exit;
lower := AFilterName.ToLower.Trim;
if lower.IsEmpty then
begin
if Assigned(AListView.Items.Filter) then
AListView.Items.Filter := nil;
end
else
begin
AListView.ItemIndex := DEFAUT_INDEX;
AListView.Items.Filter :=
function(sFilter: string): Boolean
begin
Result := (lower.IsEmpty) or sFilter.ToLower.Contains(lower);
end;
end;
end; procedure TForm1.FormCreate(Sender: TObject);
begin
LoadActivityInfoList(MainList);
LoadListView(Self.ListView1, MainList, self.dictAppIcons);
LoadListViewBitmap(Self.ListView1, MainList, self.dictAppIcons);
end; //获取安装的APP
function TForm1.GetActivityAppList: JList;
var
tempList: JList;
Intent: JIntent;
Manager: JPackageManager;
begin
Intent := TJIntent.Create;
Intent.SetAction(TJIntent.JavaClass.ACTION_MAIN);
Intent.AddCategory(TJIntent.JavaClass.CATEGORY_LAUNCHER);
Manager := SharedActivity.GetPackageManager;
tempList := nil;
tempList := Manager.QueryIntentActivities(Intent, );
Result := tempList;
end; function TForm1.GetOrSetCashAppIcon(appInfo: JApplicationInfo): TBitmap;
var
Drawable: JDrawable;
Bitmap: JBitmap;
itemBitmap: TBitmap;
Surface: TBitmapSurface;
saveDir: string;
pngFileName: string;
SaveParams: TBitmapCodecSaveParams;
begin
if not Assigned(appInfo) then
begin
Result := itemBitmap;
Exit;
end; saveDir := TPath.GetCachePath;
pngFileName := saveDir + '/' + JStringToString(appInfo.packageName) + '.png';
itemBitmap := TBitmap.Create;
if not TDirectory.Exists(saveDir, False) then
TDirectory.CreateDirectory(saveDir);
if TFile.Exists(pngFileName) then
itemBitmap.LoadFromFile(pngFileName)
else
begin
Drawable := appInfo.loadIcon(SharedActivity.getPackageManager);
Bitmap := TJBitmapDrawable.Wrap((Drawable as ILocalObject).GetObjectID).getBitmap;
Surface := TBitmapSurface.Create;
try
if JBitmapToSurface(Bitmap, Surface) then
begin
itemBitmap.Assign(Surface);
SaveParams.Quality := ;
itemBitmap.SaveToFile(pngFileName, @SaveParams);
end;
finally
Surface.Free;
end;
end;
Result := itemBitmap;
end; procedure TForm1.ListView1ItemClick(const Sender: TObject;
const AItem: TListViewItem);
begin
if not Assigned(MainList) then
Exit;
OpenApp(MainList.Items[AItem.Tag].applicationInfo.packageName,
MainList.Items[AItem.Tag].name);
Memo1.Lines.Add(JStringToString(MainList.Items[AItem.Tag].applicationInfo.packageName) + '/\' + JStringToString(MainList.Items[AItem.Tag].name));
end; procedure TForm1.LoadActivityInfoList(var List: TList<JActivityInfo>);
var
tempList: JList;
i: Integer;
ResolveInfo: JResolveInfo;
Info: JActivityInfo;
AppInfo: JApplicationInfo;
begin
if not Assigned(List) then
List := TList<JActivityInfo>.Create;
List.Clear;
tempList := Self.GetActivityAppList;
for i := to tempList.size - do
begin
ResolveInfo := TJResolveInfo.Wrap((tempList.get(i) as ILocalObject).GetObjectID);
Info := TJActivityInfo.Wrap((ResolveInfo.activityInfo as ILocalObject).GetObjectID);
AppInfo := TJApplicationInfo.Wrap((Info.applicationInfo as ILocalObject).GetObjectID);
List.Add(Info);
end;
end; procedure TForm1.LoadDictonaryAppIcons(index: Integer;
appInfo: JApplicationInfo;
var dictonaryAppIcons: TDictionary<Integer, TBitmap>);
var
itemBitmap : TBitmap;
begin
if not Assigned(dictonaryAppIcons) then
dictonaryAppIcons := TDictionary<Integer, TBitmap>.Create;
if not dictonaryAppIcons.ContainsKey(index) then
begin
itemBitmap := GetOrSetCashAppIcon(appInfo);
dictonaryAppIcons.AddOrSetValue(index, itemBitmap);
end;
end; procedure TForm1.LoadListView(listView: TListView;
AppList: TList<JActivityInfo>;
dictonaryAppIcons: TDictionary<Integer, TBitmap>);
var
tempItem : TListViewItem;
tempString, tempSubString, tempSubString2 : string;
i : integer;
begin
if (not Assigned(listView)) or (not Assigned(AppList)) then
Exit;
listView.Items.Clear;
listView.BeginUpdate;
for I := to AppList.Count - do
begin
tempString := JStringToString(AppList.Items[i].applicationInfo.loadLabel(SharedActivity.getPackageManager).toString);
tempItem := listView.Items.Add;
tempItem.Text := tempString;
tempItem.Tag := i;
end;
listView.EndUpdate;
end; procedure TForm1.LoadListViewBitmap(listView: TListView;
AppList: TList<JActivityInfo>;
var dictonaryAppIcons: TDictionary<Integer, TBitmap>);
var
i: integer;
begin
if (not Assigned(listView)) or (not Assigned(AppList)) then
Exit;
listView.BeginUpdate;
for I := to listView.ItemCount - do
begin
listView.Items[i].BeginUpdate;
LoadDictonaryAppIcons(i, AppList.Items[listView.Items[i].Tag].applicationInfo, dictonaryAppIcons);
if Assigned(dictonaryAppIcons) and (dictonaryAppIcons.ContainsKey(i)) then
listView.Items[i].Bitmap := dictonaryAppIcons.Items[i];
listView.Items[i].EndUpdate;
Application.ProcessMessages;
end;
listView.EndUpdate;
end; //打开APP方法
procedure TForm1.OpenApp(PackageName, AppName: JString);
var
Intent : JIntent;
NativeComponent : JComponentName;
begin
Intent := TJIntent.Create;
Intent.setAction(TJIntent.JavaClass.ACTION_MAIN);
Intent.addCategory(TJIntent.JavaClass.CATEGORY_LAUNCHER);
NativeComponent := TJComponentName.JavaClass.init(PackageName, AppName);
Intent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK or TJIntent.JavaClass.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
Intent.setComponent(NativeComponent);
SharedActivity.startActivity(Intent);
end; end.

Android实例-调用系统APP(XE10+小米2)的更多相关文章

  1. Android实例-获取程序版本号(XE10+小米2)

    相关资料: 383675978群号 实例源码: unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, Sy ...

  2. Java乔晓松-android中调用系统拍照功能并显示拍照的图片

    android中调用系统拍照功能并显示拍照的图片 如果你是拍照完,利用onActivityResult获取data数据,把data数据转换成Bitmap数据,这样获取到的图片,是拍照的照片的缩略图 代 ...

  3. Android Studio搭建系统App开发环境

    一.前言 在Android的体系中开发普通app使用Android Studio这一利器会非常的方便.但是开发系统app可能就会有些吃力,不过经过一些配置仍然会 很简单.我们知道系统app因为涉及到一 ...

  4. Android中调用系统所装的软件打开文件(转)

    Android中调用系统所装的软件打开文件(转) 在应用中如何调用系统所装的软件打开一个文件,这是我们经常碰到的问题,下面是我所用到的一种方法,和大家一起分享一下! 这个是打开文件的一个方法: /** ...

  5. android intent调用系统camera

    利用android的camera通常有两种方式:利用intent调用系统的camera,或者结合surfaceview实现自己定制的camera.先分别对这两种方法说明如下: 一.使用系统自配的cam ...

  6. android中调用系统的发送短信、发送邮件、打电话功能

    1 调用发送短信功能: Uri smsToUri = Uri.parse("smsto:");  Intent sendIntent = new Intent(Intent.ACT ...

  7. [Android Pro] 调用系统相机和图库,裁剪图片

    private static final int PHOTO_REQUEST_TAKEPHOTO = 1;// 拍照 private static final int PHOTO_REQUEST_GA ...

  8. Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(XE10.1+小米5)

    相关资料: 注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYi ...

  9. Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(无图)

    注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYinYinQi ...

随机推荐

  1. iOSbase64

    ios中使用BASE64进行加密和解密的方法也很简单,可以直接用google-toolbox-for-mac的GTMBase64.h来实现google-toolbox-for-mac的对应地址如下: ...

  2. HDFS小文件处理——Mapper处理

    处理小文件的时候,可以通过org.apache.hadoop.io.SequenceFile.Writer类将所有文件写出到一个seq文件中. 大致流程如下: 实现代码: package study. ...

  3. C#中控件的CheckState和Checked属性区别?

    Checked 和CheckState都是检查控件选中状态,都能判断是否选中控件. 只是Checked 通过布尔判断(true & false): CheckState 通过枚举判断. che ...

  4. Oracle过程包加密

    Oracle加绕功能可以将PL/SQL代码实现部分隐藏,如存储过程.函数.包体等均可使用加绕功能,下面以一个存储过程实现部分加绕来展示Oracle加绕功能的使用.  加绕方法一: 1.编写如下存储过程 ...

  5. shell bash判断文件或文件夹是否存在

    #shell判断文件夹是否存在 #如果文件夹不存在,创建文件夹 if [ ! -d "/myfolder" ]; then mkdir /myfolder fi #shell判断文 ...

  6. hdu 4861 Couple doubi (找规律 )

    题目链接 可以瞎搞一下,找找规律 题意:两个人进行游戏,桌上有k个球,第i个球的值为1i+2i+⋯+(p−1)i%p,两个人轮流取,如果DouBiNan的值大的话就输出YES,否则输出NO. 分析:解 ...

  7. Codeforces Round #272 (Div. 2)

    A. Dreamoon and Stairs 题意:给出n层楼梯,m,一次能够上1层或者2层楼梯,问在所有的上楼需要的步数中是否存在m的倍数 找出范围,即为最大步数为n(一次上一级),最小步数为n/2 ...

  8. WebService教程和分析

    1.1.Web Service基本概念 Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求, ...

  9. datatables 服务器返回数据后的处理-表格数据属性的操作方法(ajax.dataSrc)

    http://dt.thxopen.com/reference/option/ajax.dataSrc.html http://datatables.net/reference/option/ajax ...

  10. h.264码流解析_一个SPS的nalu及获取视频的分辨率

    00 00 00 01 67 42 00 28 E9 00  A0 0B 77 FE 00 02 00 03 C4 80  00 00 03 00 80 00 00 1A 4D 88  10 94 0 ...