Find out if a specific Android app was previously installed

前端 未结 2 1840
时光说笑
时光说笑 2021-02-10 10:45

I have an App which provides you a list of various apps that you can download and install from Play Store to earn goodies. Now, I don\'t want a user to uninstall

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-10 11:35

    This snippet will log all the main activities of the apps installed on you device, you just have to check that list for a given app

    final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    final List  pkgAppsList = getPackageManager().queryIntentActivities( mainIntent, 0);
    
    for(ResolveInfo resolve : pkgAppsList)
    {
        Log.d("MY_APP", resolve.toString());
    }
    

    Hope it helps!

提交回复
热议问题