Thank you for your quick response. I tried it before posting but end with error. May be I am doing wrong. Following is the thing I am doing to get the package name ...
B4X:
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
usm.Initialize("")
Log(DateTime.Now)
Dim starttime As Long
starttime = DateTime.DateParse("09/06/2018" & " " & DateTime.TimeParse("00:00:00"))
starttime = DateTime.DateParse(DateTime.Date(DateTime.Now))
Dim endtime As Long
endtime = DateTime.Now
Dim PM As PackageManager
Dim usage1 As List = usm.queryUsageStats(starttime,endtime)
For i = 0 To usage1.Size-1
Dim us As UsageStats = usage1.Get(i)
' Log(us)
If us.TotalTimeInForeground <> 0 Then
PM.GetApplicationLabel(us.PackageName)
' Log(us.PackageName & ", " & ConvertMillisecondsToString(us.TotalTimeInForeground))
Log(PM.GetApplicationLabel(us.PackageName) & ", " & ConvertMillisecondsToString(us.TotalTimeInForeground))
End If
Next
End Sub