Skip to main content

Android Lock Apps


I'm new here and I've searched for questions to help me but I have no clear answers.



I need to make an application to block other applications on the phone. I've seen several on the market but I want to make one. is there any way of knowing when a user tries to open an application and bring forward an activity? (to put the password).



I tried with FileObserver, but only works with files and directories (obviously). Could I make a listener that captures the Intent of the other applications before starting?



I apologize for my english and I appreciate your help!


Source: Tips4allCCNA FINAL EXAM

Comments

  1. No you cannot know when another application is launched without some kind of hack.
    This is because application launches are not broadcasted.

    What you can do is creating a service running on fixed intervals , say 1000 milliseconds, that checks what non system application is on front. Kill that app and from the service pop a password input box. If that password is correct relaunch that application

    Here is some code sample

    timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask() {
    public void run() {
    List<RunningAppProcessInfo> appProcesses= activityManager.getRunningAppProcesses();
    for (RunningAppProcessInfo appProcess : appProcesses) {
    try {
    if (appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
    if (!lastFrontAppPkg.equals((String) appProcess.pkgList[0])) {
    apkInfo = ApkInfo.getInfoFromPackageName(appProcess.pkgList[0], mContext);
    if (apkInfo == null || (apkInfo.getP().applicationInfo.flags && ApplicationInfo.FLAG_SYSTEM) == 1) {
    // System app continue;
    } else if (((apkInfo.getP().versionName == null)) || (apkInfo.getP().requestedPermissions == null)) {
    //Application that comes preloaded with the device
    continue;
    } else {
    lastFrontAppPkg = (String) appProcess.pkgList[0];
    }
    //kill the app
    //Here do the pupop with password to launch the lastFrontAppPkg if the pass is correct
    }
    }
    }
    } catch (Exception e) {
    //e.printStackTrace();
    }
    }
    }
    }, 0, 1000);


    And here is the ApkInfo.getInfoFromPackageName()

    /**
    * Get the ApkInfo class of the packageName requested
    *
    * @param pkgName
    * packageName
    * @return ApkInfo class of the apk requested or null if package name
    * doesn't exist
    * @see ApkInfo
    */
    public static ApkInfo getInfoFromPackageName(String pkgName,
    Context mContext) {
    ApkInfo newInfo = new ApkInfo();
    try {
    PackageInfo p = mContext.getPackageManager().getPackageInfo(
    pkgName, PackageManager.GET_PERMISSIONS);

    newInfo.appname = p.applicationInfo.loadLabel(
    mContext.getPackageManager()).toString();
    newInfo.pname = p.packageName;
    newInfo.versionName = p.versionName;
    newInfo.versionCode = p.versionCode;
    newInfo.icon = p.applicationInfo.loadIcon(mContext
    .getPackageManager());
    newInfo.setP(p);
    } catch (NameNotFoundException e) {
    e.printStackTrace();
    return null;
    }
    return newInfo;
    }

    ReplyDelete
  2. That service that checks every second will drain your battery in a couple hours.

    Wouldn't it be better to make a launcher / home app?

    ReplyDelete

Post a Comment

Popular posts from this blog

[韓日関係] 首相含む大幅な内閣改造の可能性…早ければ来月10日ごろ=韓国

div not scrolling properly with slimScroll plugin

I am using the slimScroll plugin for jQuery by Piotr Rochala Which is a great plugin for nice scrollbars on most browsers but I am stuck because I am using it for a chat box and whenever the user appends new text to the boxit does scroll using the .scrollTop() method however the plugin's scrollbar doesnt scroll with it and when the user wants to look though the chat history it will start scrolling from near the top. I have made a quick demo of my situation http://jsfiddle.net/DY9CT/2/ Does anyone know how to solve this problem?

Why does this javascript based printing cause Safari to refresh the page?

The page I am working on has a javascript function executed to print parts of the page. For some reason, printing in Safari, causes the window to somehow update. I say somehow, because it does not really refresh as in reload the page, but rather it starts the "rendering" of the page from start, i.e. scroll to top, flash animations start from 0, and so forth. The effect is reproduced by this fiddle: http://jsfiddle.net/fYmnB/ Clicking the print button and finishing or cancelling a print in Safari causes the screen to "go white" for a sec, which in my real website manifests itself as something "like" a reload. While running print button with, let's say, Firefox, just opens and closes the print dialogue without affecting the fiddle page in any way. Is there something with my way of calling the browsers print method that causes this, or how can it be explained - and preferably, avoided? P.S.: On my real site the same occurs with Chrome. In the ex