How to handle app dependencies to 3d party

前端 未结 1 1818
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-06 02:33

The app I\'m currently developing depends on a third party application (OIFileManager).

My question is what is the general way to handle these kind of dependancies?

相关标签:
1条回答
  • 2021-02-06 03:14

    There's no automatic way. The user will have to install the dependency from Android Market (or some other source) manually.

    Intent scanIntent = new Intent("com.google.zxing.client.android.SCAN");
    Intent marketIntent = new Intent(ACTION_VIEW, Uri.parse("market://details?id=com.google.zxing.client.android"));
    
    try {
        startActivityForResult(scanIntent);
    } catch (ActivityNotFoundException e) {
        try {
            // show a prompt here
            startActivity(marketIntent);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, "Market not installed.", LENGTH_SHORT).show();
        }
    
    }
    

    So you:

    • try to launch the scanner;
    • if fails, prompt user to install it from Android Market;
    • if fails, the Market is not installed.
    0 讨论(0)
提交回复
热议问题