码迷,mamicode.com
首页 > 移动开发 > 详细

delphi在手机桌面图标上显示数字

时间:2017-11-27 16:46:09      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:tco   桌面   tac   except   cal   getc   get   delphi   ber   

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在手机桌面图标上显示数字

标签:tco   桌面   tac   except   cal   getc   get   delphi   ber   

原文地址:http://www.cnblogs.com/dannylee/p/7904185.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!