Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 查找应用程序是否已安装。。?_Android_Installation - Fatal编程技术网

Android 查找应用程序是否已安装。。?

Android 查找应用程序是否已安装。。?,android,installation,Android,Installation,我浏览了很多链接和教程,如和,但我没有找到我的问题的确切解决方案。当我试图安装一个启动程序包为com.test.app的应用程序时,我想在安装时检查这个程序包,或者你可以说我们的应用程序是否已经安装? 当我试图在上面的链接,它总是显示“安装”为我无论是安装或不安装。那么我将如何处理这个问题。这是一个想法。我已经实施了 1. Create a Web Service which our app can pull whenever the app launches or b

我浏览了很多链接和教程,如和,但我没有找到我的问题的确切解决方案。当我试图安装一个启动程序包为com.test.app的应用程序时,我想在安装时检查这个程序包,或者你可以说我们的应用程序是否已经安装?
当我试图在上面的链接,它总是显示“安装”为我无论是安装或不安装。那么我将如何处理这个问题。

这是一个想法。我已经实施了

     1. Create a Web Service which our app can pull whenever the app
        launches or based on some time limit that can check if there is new version out there.
     2. This Web service should return the latest Version of the apk file that is hosted on the
        Server along with the URI of the application file that has the new version.
     3. When your app gets the response from the Web Service, it will parse the JSON and
        check our app version to the latest version that is available
        on the server.
     4. If our app version is lower than the latest version it will prompt
        the user to start the download process.
     5. Today i manage download process by the Download Manager and day before
        yesterday I do same thing by Package Manager. I will update which mechanism is
        most optimal to download .apk file with size of more than 10MB.
     6. The download manager will notify our app using Broadcast receiver when the  download
        is complete.
     7. Upon completion of the latest version of the application file the we can  
        start the activity to install that file.
然后,我们可以比较不同的版本

    private static int compare(String v1, String v2) {   
        String s1 = normalisedVersion(v1);
        String s2 = normalisedVersion(v2);
        int cmp = s1.compareTo(s2);
        System.out.println("cmp int  "+cmp);

        return cmp;
       /* String cmpStr = cmp < 0 ? "<" : cmp > 0 ? ">" : "==";

        System.out.printf("'%s' %s '%s'%n", v1, cmpStr, v2);*/
    }

好的,我有解决方案,我给你一个链接,提供所有安装的应用程序名、包名和其他信息。你可以在那里检查特定的包名。如果你有任何问题,请告诉我。首先尝试一下你应得的。。谢谢你的快速回复…嘿,戈帕尔·拉奥。。在安装应用程序“A”期间,是否可以检查应用程序“A”是否已安装。。。。?使用一些系统服务是可能的吗?我不知道……是的,我知道。。我可以通过使用web服务来做到这一点。感谢所有人。请告诉我我的想法是否可行?一般来说,谷歌游戏应用程序将负责在真实设备中更新应用程序。我们不需要手动检查我们的应用程序的更新,因为这是GooglePlay应用程序的责任。我不能说这是否可行,因为我从未遇到过这种情况……是的……当然……你可以问
    public static String normalisedVersion(String version) {
        return normalisedVersion(version, ".", 4);
    }

    public static String normalisedVersion(String version, String sep, int maxWidth) {
        String[] split = Pattern.compile(sep, Pattern.LITERAL).split(version);
        StringBuilder sb = new StringBuilder();
        for (String s : split) {
            sb.append(String.format("%" + maxWidth + 's', s));
        }
        return sb.toString();
    }