相关资料:

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. 前端html、Javascript、CSS技术小结

    简单地总结了一下前端用过的html.javascript.css技术,算是清点一下,做个大略的小结,为进一步的学习给个纲领. 一.HTML 由于HTML5的兴起,简单地判断一个网页是否是html5网页 ...

  2. Listbox与Listbox with key的区别

    标准解释: ListboxVisualization as listbox in which a list of entries is displayed with one short descrip ...

  3. 【由VerySky原创】由Number Range 导致凭证生成但无法保存的问题

    工厂正常生产,但某天突然发生车辆下线失败销售入库报错( MFBF凭证不能保存\ 下线车无法产生131 )的问题: ST22发现程序dump信息 分析 | SAPSQL_ARRAY_INSERT_DUP ...

  4. c# 客户端

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  5. Android 下压缩图片&mdash;微弱失真

    Android下压缩图片的方法: 大概能将3M左右的图片压缩到100K左右, 几乎不失真. 代码如下: import java.io.FileNotFoundException; import jav ...

  6. luogu【P3387】【模板】缩点

    原题入口 PS:这个题数据是由Hany01大大出出来的 %%% 这个题显然是一道强联通+DAGdp的题 (题目背景有= =) 缩点的原因就是:不缩会一直在一个地方绕圈圈 而且不能进行后面的DAPdp ...

  7. 【洛谷3047】[USACO12FEB]附近的牛Nearby Cows

    题面 题目描述 Farmer John has noticed that his cows often move between nearby fields. Taking this into acc ...

  8. 017-封装-OC笔记

    学习目标 1.[了解]异常处理 2.[掌握]类方法 3.[掌握]NSString类 4.[掌握]匿名对象 5.[掌握]封装实例变量 6.[掌握]对象之间的关系 一.异常处理 什么是异常? 代码完全符合 ...

  9. 解决SpringBoot的@Autowired无法注入问题

    问题:@Autowired无法自动注入 思路:SpringBoot项目的Bean装配默认规则是根据Application类所在的包位置从上往下扫描!"Application类"是指 ...

  10. LeetCode: Binary Tree Postorder Traversal 解题报告

    Binary Tree Postorder Traversal Given a binary tree, return the postorder traversal of its nodes' va ...