How to handle app dependencies to 3d party

做~自己de王妃 提交于 2019-12-03 02:58:07

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.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!