Download app if intent not installed

前端 未结 2 1970
感情败类
感情败类 2021-01-01 02:30

I know I have seen a way of calling an Intent, and if it doesn\'t exist the function will redirect to market for download the application that has the intent.

Right

相关标签:
2条回答
  • 2021-01-01 02:57

    To check if some Intent is available:

    String intentToCheck = "com.google.SCAN"; //can be any other intent
    final PackageManager packageManager = getPackageManager();
    final Intent intent = new Intent(intentToCheck);
    List list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    final boolean isAvailable = list.size() > 0;
    

    To open Google Market via Intent:

    Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:com.google.scan"));
    startActivity(marketIntent); 
    
    0 讨论(0)
  • 2021-01-01 03:19

    I haven't done this before but in theory it is just another Intent call with a view flag and the market://... URI pointing to the application.

    0 讨论(0)
提交回复
热议问题