android.content.ActivityNotFoundException#printStackTrace ( )源码实例Demo

下面列出了android.content.ActivityNotFoundException#printStackTrace ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Tok-Android   文件: PageJumpOut.java
/**
 * open system file manager
 *
 * @param activity activity
 * @param type file type
 * @param requestCode code
 * @param extraMimeType mimiType must be arrays
 */
private static void select(Activity activity, String type, int requestCode,
    String... extraMimeType) {
    Intent intent = new Intent();
    intent.setType(type);
    intent.putExtra(Intent.EXTRA_MIME_TYPES, extraMimeType);
    intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
    try {
        activity.startActivityForResult(intent, requestCode);
    } catch (ActivityNotFoundException e) {
        intent.setAction(Intent.ACTION_GET_CONTENT);
        try {
            activity.startActivityForResult(intent, requestCode);
        } catch (ActivityNotFoundException e2) {
            e2.printStackTrace();
        }
    }
}
 
源代码2 项目: DocUIProxy-Android   文件: ProxyCameraActivity.java
private void processIntentForOthers(@NonNull Intent intent) {
    final ComponentName preferredCamera = Settings.getInstance().getPreferredCamera();
    boolean launched = false;
    if (preferredCamera != null) {
        Log.d(TAG, "Launch preferred camera: " + preferredCamera.toString());
        try {
            onStartCameraApp(preferredCamera);
            launched = true;
        } catch (ActivityNotFoundException e) {
            e.printStackTrace();
            Settings.getInstance().setPreferredCamera(null);
        }
    }
    if (!launched) {
        CameraChooserDialogFragment
                .newInstance()
                .show(getFragmentManager(), "CameraChooser");
    }
}
 
源代码3 项目: pandora   文件: PermissionReqFragment.java
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (code == requestCode) {
        if (resultCode == Activity.RESULT_OK) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                if (!Settings.canDrawOverlays(getContext())) {
                    try {
                        Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
                        intent.setData(Uri.parse("package:" + getContext().getPackageName()));
                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        getActivity().startActivity(intent);
                    } catch (ActivityNotFoundException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        getActivity().finish();
    }
}
 
public void generateInvoice(OrderEntity orderData) {
    ActivityCompat.requestPermissions((BaseActivity) context, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, 666);
    int result = ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    if (result == PackageManager.PERMISSION_GRANTED) {
        if (Helper.getInstanse().generateInvoice(context, orderData) != null) {
            File file = Helper.getInstanse().generateInvoice(context, orderData);
            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
            StrictMode.setVmPolicy(builder.build());
            Uri path = Uri.fromFile(file);
            Intent pdfOpenIntent = new Intent(Intent.ACTION_VIEW);
            pdfOpenIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            pdfOpenIntent.setDataAndType(path, "application/pdf");
            try {
                context.startActivity(pdfOpenIntent);
            } catch (ActivityNotFoundException e) {
                e.printStackTrace();
                ToastHelper.showToast(context,
                        "No Application Available to View PDF",
                        Toast.LENGTH_SHORT);
            }
        } else
            ToastHelper.showToast(context,
                    "ERROR in generating pdf",
                    Toast.LENGTH_SHORT);
    }
}
 
public void printInvoice(OrderEntity orderData) {
    ActivityCompat.requestPermissions((BaseActivity) context, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, 666);
    int result = ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    if (result == PackageManager.PERMISSION_GRANTED) {
        if (Helper.getInstanse().generateInvoice(context, orderData) != null) {
            File file = Helper.getInstanse().generateInvoice(context, orderData);
            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
            StrictMode.setVmPolicy(builder.build());
            Uri path = Uri.fromFile(file);
            Intent pdfOpenIntent = new Intent(Intent.ACTION_VIEW);
            pdfOpenIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            pdfOpenIntent.setDataAndType(path, "application/pdf");
            try {
                context.startActivity(pdfOpenIntent);
            } catch (ActivityNotFoundException e) {
                e.printStackTrace();
                ToastHelper.showToast(context,
                        "No Application Available to View PDF",
                        Toast.LENGTH_SHORT);
            }
        } else
            ToastHelper.showToast(context,
                    "ERROR in generating pdf",
                    Toast.LENGTH_SHORT);
    }
}
 
源代码6 项目: Tok-Android   文件: PageJumpOut.java
private static void create(Activity activity, String type, int requestCode,
    String... extraMimeType) {
    Intent intent = new Intent();
    // intent.setType(type);
    //intent.putExtra(Intent.EXTRA_MIME_TYPES, extraMimeType);
    intent.setAction(Intent.ACTION_OPEN_DOCUMENT_TREE);
    try {
        activity.startActivityForResult(intent, requestCode);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    }
}
 
源代码7 项目: AndroidFastScroll   文件: MainFragment.java
private void viewOnGitHub() {
    try {
        startActivity(new Intent(Intent.ACTION_VIEW, GITHUB_URI));
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
        Toast.makeText(requireContext(), e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
    }
}
 
源代码8 项目: SmartFlasher   文件: Utils.java
public static void launchUrl(String url, Context context) {
    if (Utils.networkUnavailable(context)) {
        Utils.toast(R.string.no_internet, context);
        return;
    }
    try {
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        context.startActivity(i);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
    }
}
 
源代码9 项目: BmapLite   文件: FavoriteActivity.java
private void importFav() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("*/json");//设置类型
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    try {
        startActivityForResult(intent, 222);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
        onMessage("抱歉,未找到文件管理器程序");
    }
}
 
源代码10 项目: BaldPhone   文件: SingleContactActivity.java
@Override
public void startActivity(Intent intent) {
    try {
        super.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, e.getMessage());
        e.printStackTrace();
        BaldToast.error(this);
    }
}
 
源代码11 项目: BaldPhone   文件: BaseContactsActivity.java
private void displaySpeechRecognizer() {
    try {
        startActivityForResult(
                new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
                        .putExtra(
                                RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                                RecognizerIntent.LANGUAGE_MODEL_FREE_FORM
                        ),
                SPEECH_REQUEST_CODE);
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, S.str(e.getMessage()));
        e.printStackTrace();
        BaldToast.error(this);
    }
}
 
源代码12 项目: BaldPhone   文件: HomeScreenActivity.java
public void displaySpeechRecognizer() {
    try {
        startActivityForResult(
                new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
                        .putExtra(
                                RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                                RecognizerIntent.LANGUAGE_MODEL_FREE_FORM
                        ),
                SPEECH_REQUEST_CODE);
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, S.str(e.getMessage()));
        e.printStackTrace();
        BaldToast.error(this);
    }
}
 
源代码13 项目: BmapLite   文件: FavoriteActivity.java
private void importFav() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("*/json");//设置类型
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    try {
        startActivityForResult(intent, 222);
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
        onMessage("抱歉,未找到文件管理器程序");
    }
}
 
源代码14 项目: Deadline   文件: StartIntentUtils.java
public static boolean startIntentUrl(Activity activity, String intentFullUrl) {
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(intentFullUrl));
        activity.startActivity(intent);
        return true;
    } catch (ActivityNotFoundException e) {
        e.printStackTrace();
        return false;
    }
}
 
源代码15 项目: AcgClub   文件: IntentUtils.java
/**
 * 跳转到应用市场
 *
 * @param context 上下文
 * @param packageName 应用包名
 * @return 跳转是否成功
 */
public static boolean go2Market(Context context, String packageName) {
  Uri uri = Uri.parse("market://details?id=" + packageName);
  Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
  goToMarket.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  try {
    context.startActivity(goToMarket);
    return true;
  } catch (ActivityNotFoundException e) {
    e.printStackTrace();
    return false;
  }
}
 
源代码16 项目: ToDoList   文件: PermissionPageUtils.java
private void goMeizuMainager() {
    try {
        Intent intent = new Intent("com.meizu.safe.security.SHOW_APPSEC");
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra("packageName", packageName);
        mContext.startActivity(intent);
    } catch (ActivityNotFoundException localActivityNotFoundException) {
        localActivityNotFoundException.printStackTrace();
        goIntentSetting();
    }
}
 
源代码17 项目: ConvertWebViewToPdfDemo   文件: PdfView.java
/**
 * @param activity pass the current activity context
 * @param path storage full path
 */
private  static void fileChooser(Activity activity, String path) {
    File file = new File(path);
    Intent target = new Intent("android.intent.action.VIEW");
    Uri uri = FileProvider.getUriForFile(activity, "com.package.name.fileprovider", file);
    target.setDataAndType(uri, "application/pdf");
    target.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    Intent intent = Intent.createChooser(target, "Open File");
    try {
        activity.startActivity(intent);
    } catch (ActivityNotFoundException var6) {
        var6.printStackTrace();
    }

}
 
源代码18 项目: PowerFileExplorer   文件: Futils.java
/**
   * Open a file not supported by Amaze
   * @param f the file
   * @param c
   * @param forcechooser force the chooser to show up even when set default by user
   */
  public static void openunknown(File f, Context c, boolean forcechooser) {
      Intent intent = new Intent();
      intent.setAction(android.content.Intent.ACTION_VIEW);
String type = MimeTypes.getMimeType(f);
      Log.d(TAG, "openunknown " + f + ", " + forcechooser + ", " + type);
      if (type != null && type.trim().length() != 0 && !type.equals("*/*")) {

          //Uri uri=fileToContentUri(c, f);
          //if(uri==null) 
	Uri uri=Uri.fromFile(f);
          intent.setDataAndType(uri, type);

          Intent startintent;
          if (forcechooser) {
              startintent = Intent.createChooser(intent, c.getResources().getString(R.string.openwith));
          } else {
              startintent = intent;
          }
          try {
              c.startActivity(startintent);
          } catch (ActivityNotFoundException e) {
              e.printStackTrace();
              Toast.makeText(c, R.string.noappfound, Toast.LENGTH_SHORT).show();
              openWith(f, c);
          }
      } else {
          // failed to load mime type
          openWith(f, c);
      }
  }
 
源代码19 项目: AndroidDocumentViewer   文件: WPSOpenUtils.java
/**
     * 用WPS 打开应用
     *
     * @param context Context 对象
     * @param intent  设置好数据了类型的intent
     * @return
     */
    protected static boolean doRealWPSViewOrEdit(@NonNull ActivityStarterWrapper context, @NonNull Intent intent,
                                                 boolean readOnly, int requestCode) {
        Bundle bundle = new Bundle();
        bundle.putBoolean(WPSModel.SEND_CLOSE_BROAD, true); // 关闭时是否发送广播
        bundle.putBoolean(WPSModel.SEND_SAVE_BROAD, true); // 保存时是否发送广播
        bundle.putString(WPSModel.THIRD_PACKAGE, context.getPackageName()); // 第三方应用的包名,用于对改应用合法性的验证
        if (readOnly) {
            bundle.putString(WPSModel.OPEN_MODE, WPSModel.OpenMode.READ_ONLY); // 打开模式
        } else {
            bundle.putString(WPSModel.OPEN_MODE, WPSModel.OpenMode.NORMAL); // 打开模式
            bundle.putBoolean(WPSModel.ENTER_REVISE_MODE, true); // 修订模式
        }
        bundle.putBoolean(WPSModel.CLEAR_TRACE, true);// 清除打开记录
//        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
//        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        intent.setAction(Intent.ACTION_VIEW);
        intent.setClassName(WPSModel.PackageName.NORMAL, WPSModel.ClassName.NORMAL);
        intent.putExtras(bundle);
        try {
            if (readOnly) {
                context.startActivity(Intent.createChooser(intent, "请选择WPS打开文件"));
            } else {
                context.startActivityForResult(Intent.createChooser(intent, "请选择WPS打开应用"), requestCode);
            }
        } catch (ActivityNotFoundException exception) {
            Log.d("WPSOpenUtils", exception.getMessage());
            exception.printStackTrace();
            return false;
        }
        return true;
    }
 
源代码20 项目: VideoOS-Android-SDK   文件: JsBridge.java
private boolean startApp(Uri uri) {
    try {
        Intent intent = new Intent();
        intent.setData(uri);
        intent.setAction(Intent.ACTION_VIEW);
        mContext.startActivity(intent);
        return true;
    } catch (ActivityNotFoundException e) {
        VenvyLog.i("打开支付包出错");
        e.printStackTrace();
        return false;
    }

}