Android Question get package name on android 5

Discussion in 'Android Questions' started by ArminKH, Jul 14, 2015.

  1. ArminKH

    ArminKH Well-Known Member

    Hello every body
    I am going to develop an app which is a security app like locker apps
    By using this app we can lock each place of our phone such as gallery,file manager,etc...
    Now i want to Get package name for every app which is started by user and must be unlocked after user entered correct pass or pattern ,...
    Here is my code
    Code:
    Dim R As Reflector
        R.Target=R.GetContext
        ActMan = R.RunMethod2(
    "getSystemService","activity","java.lang.String")

    Dim TaskInfo As JavaObject = ActMan.RunMethod("getRunningTasks",Array As Object(1))
        
    Dim CompInfo As JavaObject = TaskInfo.RunMethodJO("get",Array As Object(0)).GetField("topActivity")
        
    Dim PackageName As String = CompInfo.RunMethod("getPackageName",Null)
    Log(PackageName)
    By using this code we can get package name for each running app but not worked on android +5 without any error and just return luncher package name
    Tnx all
     
  2. DonManfred

    DonManfred Expert Licensed User

    Did you set the right permissions in manifest? Maybe
    Code:
    AddPermission(android.permission.GET_TASKS) ' Allows an application to get information about the currently or recently running tasks.
     
    ArminKH likes this.
  3. sonicmayne

    sonicmayne Member Licensed User

    ArminKH likes this.
  4. ArminKH

    ArminKH Well-Known Member

  5. ArminKH

    ArminKH Well-Known Member

    Yes but still not worked
     
  6. DonManfred

    DonManfred Expert Licensed User

    I think the answer from @sonicmayne is responsible. I did not know that this has changed in Android L (Lollipop = 5)
     
    sonicmayne and ArminKH like this.
  7. ArminKH

    ArminKH Well-Known Member

    Yes but i'm not familar with java.i am looking for a way on h4a
     
  8. ArminKH

    ArminKH Well-Known Member

    Have u the corect code which is working on android +5?
    If is possible please correct my code for android +5
    I'm not so much familar with java and reflection methods
     
  9. DonManfred

    DonManfred Expert Licensed User

    no, i dont have a working code
     
    ArminKH likes this.
  10. sonicmayne

    sonicmayne Member Licensed User

    It seems like Google really really doesn't want you getting other application's information, such as this.

    I couldn't get the UsageStatsManager way of getting package names working, only the getRunningAppProcesses. This works on Android L, but does not work on Android M.
     
    ArminKH likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice