delphi在手机桌面图标上显示数字
Posted 竹鹿风清
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了delphi在手机桌面图标上显示数字相关的知识,希望对你有一定的参考价值。
function getLauncherClassName: JString; var str : JString; localPackageManager : JPackageManager; Intent: JIntent; localIterator : JIterator; localResolveInfo : JResolveInfo; begin localPackageManager := SharedActivity.getPackageManager; Intent := TJIntent.JavaClass.init(StringToJString(‘android.intent.action.MAIN‘)); Intent.addCategory(StringToJString(‘android.intent.category.LAUNCHER‘)); try localIterator := localPackageManager.queryIntentActivities(Intent,0).iterator; while localIterator.hasNext do begin localResolveInfo := TJResolveInfo.Wrap((localIterator.next as ILocalObject).GetObjectID); if (not localResolveInfo.activityInfo.applicationInfo.packageName.equalsIgnoreCase(SharedActivity.getPackageName)) then Continue; Result := localResolveInfo.activityInfo.name; Break; end; except end; end; procedure setHuaweiBadge(num: Integer); var str : JString; localBundle : JBundle; begin str := getLauncherClassName; if JStringToString(str) <> ‘‘ then begin localBundle := TJBundle.JavaClass.init; localBundle.putString(StringToJString(‘package‘), SharedActivityContext.getPackageName()); localBundle.putString(StringToJString(‘class‘), str); localBundle.putInt(StringToJString(‘badgenumber‘), 3); SharedActivityContext.getContentResolver.call(StrToJURI(‘content://com.huawei.android.launcher.settings/badge/‘),StringToJString(‘change_badge‘),StringToJString(‘null‘),localBundle); end; end;
现在手头上只有华为的手机,其他没有经过测试的代码就不贴出来了,自己找java代码转换。
判断手机类型:TJBuild.JavaClass.MANUFACTURER.EqualsIgnoreCase(StringToJString(‘huawei‘))
以上是关于delphi在手机桌面图标上显示数字的主要内容,如果未能解决你的问题,请参考以下文章