Java Code Examples for android.content.ActivityNotFoundException#printStackTrace()
The following examples show how to use
android.content.ActivityNotFoundException#printStackTrace() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Tok-Android File: PageJumpOut.java License: GNU General Public License v3.0 | 6 votes |
/** * 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(); } } }
Example 2
Source Project: DocUIProxy-Android File: ProxyCameraActivity.java License: GNU General Public License v3.0 | 6 votes |
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"); } }
Example 3
Source Project: pandora File: PermissionReqFragment.java License: Apache License 2.0 | 6 votes |
@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(); } }
Example 4
Source Project: mobikul-standalone-pos File: OrderFragmentHandler.java License: MIT License | 6 votes |
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); } }
Example 5
Source Project: mobikul-standalone-pos File: OrderPlacedHandler.java License: MIT License | 6 votes |
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); } }
Example 6
Source Project: Tok-Android File: PageJumpOut.java License: GNU General Public License v3.0 | 5 votes |
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(); } }
Example 7
Source Project: AndroidFastScroll File: MainFragment.java License: Apache License 2.0 | 5 votes |
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(); } }
Example 8
Source Project: SmartFlasher File: Utils.java License: GNU General Public License v3.0 | 5 votes |
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(); } }
Example 9
Source Project: BmapLite File: FavoriteActivity.java License: GNU General Public License v3.0 | 5 votes |
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("抱歉,未找到文件管理器程序"); } }
Example 10
Source Project: BaldPhone File: SingleContactActivity.java License: Apache License 2.0 | 5 votes |
@Override public void startActivity(Intent intent) { try { super.startActivity(intent); } catch (ActivityNotFoundException e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); BaldToast.error(this); } }
Example 11
Source Project: BaldPhone File: BaseContactsActivity.java License: Apache License 2.0 | 5 votes |
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); } }
Example 12
Source Project: BaldPhone File: HomeScreenActivity.java License: Apache License 2.0 | 5 votes |
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); } }
Example 13
Source Project: BmapLite File: FavoriteActivity.java License: Apache License 2.0 | 5 votes |
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("抱歉,未找到文件管理器程序"); } }
Example 14
Source Project: Deadline File: StartIntentUtils.java License: GNU General Public License v3.0 | 5 votes |
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; } }
Example 15
Source Project: AcgClub File: IntentUtils.java License: MIT License | 5 votes |
/** * 跳转到应用市场 * * @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; } }
Example 16
Source Project: ToDoList File: PermissionPageUtils.java License: Apache License 2.0 | 5 votes |
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(); } }
Example 17
Source Project: ConvertWebViewToPdfDemo File: PdfView.java License: MIT License | 5 votes |
/** * @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(); } }
Example 18
Source Project: PowerFileExplorer File: Futils.java License: GNU General Public License v3.0 | 5 votes |
/** * 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); } }
Example 19
Source Project: AndroidDocumentViewer File: WPSOpenUtils.java License: MIT License | 5 votes |
/** * 用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; }
Example 20
Source Project: VideoOS-Android-SDK File: JsBridge.java License: GNU General Public License v3.0 | 5 votes |
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; } }