List of usage examples for android.content ActivityNotFoundException toString
public String toString()
From source file:og.android.tether.MainActivity.java
private void openAdBar() { LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View ad_view = li.inflate(R.layout.ad_view, null); ad_view.setBackgroundColor(Color.TRANSPARENT); final WindowManager wm = getWindowManager(); WindowManager.LayoutParams wmParams = new WindowManager.LayoutParams(); wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT; wmParams.width = WindowManager.LayoutParams.WRAP_CONTENT; wmParams.gravity = Gravity.BOTTOM;/*from w w w.j a v a2s . co m*/ wmParams.y = 100; wmParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; wmParams.format = PixelFormat.TRANSLUCENT; wm.addView(ad_view, wmParams); View ad_open = ad_view.findViewById(R.id.ad_open); View ad_close = ad_view.findViewById(R.id.ad_close); OnClickListener adListener = new OnClickListener() { @Override public void onClick(View v) { switch (v.getId()) { case R.id.ad_open: Log.i(MSG_TAG, "ad_open"); Intent i = new Intent(); i.setAction(Intent.ACTION_VIEW); i.addCategory(Intent.CATEGORY_BROWSABLE); i.setData(Uri.parse( "market://details?id=com.opengarden.radiofreenet&referrer=utm_source%3Dog.android.tether%26utm_medium%3Dandroid%26utm_campaign%3Dbanner%26utm_content%3Dinstall")); try { startActivity(i); } catch (android.content.ActivityNotFoundException e) { Log.e(MSG_TAG, "", e); MainActivity.this.application.displayToastMessage(e.toString()); } break; case R.id.ad_close: Log.i(MSG_TAG, "ad_close"); wm.removeView(ad_view); break; default: Log.i(MSG_TAG, "default"); break; } } }; ad_open.setOnClickListener(adListener); ad_close.setOnClickListener(adListener); }
From source file:com.initialxy.cordova.themeablebrowser.ThemeableBrowser.java
/** * Display a new browser with the specified URL. * * @param url//from ww w . j ava 2s .c om * @return */ public String openExternal(String url) { try { Intent intent = null; intent = new Intent(Intent.ACTION_VIEW); // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent". // Adding the MIME type to http: URLs causes them to not be handled by the downloader. Uri uri = Uri.parse(url); if ("file".equals(uri.getScheme())) { intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri)); } else { intent.setData(uri); } intent.putExtra(Browser.EXTRA_APPLICATION_ID, cordova.getActivity().getPackageName()); this.cordova.getActivity().startActivity(intent); return ""; } catch (android.content.ActivityNotFoundException e) { Log.d(LOG_TAG, "ThemeableBrowser: Error loading url " + url + ":" + e.toString()); return e.toString(); } }
From source file:com.vuze.android.remote.fragment.FilesFragment.java
@SuppressWarnings("unused") protected boolean reallyStreamFile(Map<?, ?> selectedFile) { final String contentURL = getContentURL(selectedFile); if (contentURL != null && contentURL.length() > 0) { Uri uri = Uri.parse(contentURL); Intent intent = new Intent(Intent.ACTION_VIEW, uri); String name = MapUtils.getMapString(selectedFile, "name", "video"); intent.putExtra("title", name); String extension = MimeTypeMap.getFileExtensionFromUrl(contentURL).toLowerCase(Locale.US); String mimetype = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); if (mimetype != null && tryLaunchWithMimeFirst) { intent.setType(mimetype);// www. ja va2s . com } Class<?> fallBackIntentClass = VideoViewer.class; if (mimetype != null && mimetype.startsWith("image")) { fallBackIntentClass = ImageViewer.class; } final PackageManager packageManager = getActivity().getPackageManager(); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (AndroidUtils.DEBUG) { Log.d(TAG, "num intents " + list.size()); for (ResolveInfo info : list) { ComponentInfo componentInfo = AndroidUtils.getComponentInfo(info); Log.d(TAG, info.toString() + "/" + (componentInfo == null ? "null" : (componentInfo.name + "/" + componentInfo))); } } if (list.size() == 0) { // Intent will launch, but show message to the user: // "Opening web browser links is not supported" intent.setClass(getActivity(), fallBackIntentClass); } if (list.size() == 1) { ResolveInfo info = list.get(0); ComponentInfo componentInfo = AndroidUtils.getComponentInfo(info); if (componentInfo != null && componentInfo.name != null) { if ("com.amazon.unifiedshare.actionchooser.BuellerShareActivity".equals(componentInfo.name) || componentInfo.name.startsWith("com.google.android.tv.frameworkpackagestubs.Stubs")) { intent.setClass(getActivity(), fallBackIntentClass); } } } try { startActivity(intent); if (AndroidUtils.DEBUG) { Log.d(TAG, "Started " + uri + " MIME: " + intent.getType()); } } catch (java.lang.SecurityException es) { if (AndroidUtils.DEBUG) { Log.d(TAG, "ERROR launching. " + es.toString()); } if (mimetype != null) { try { Intent intent2 = new Intent(Intent.ACTION_VIEW, uri); intent2.putExtra("title", name); if (!tryLaunchWithMimeFirst) { intent2.setType(mimetype); } list = packageManager.queryIntentActivities(intent2, PackageManager.MATCH_DEFAULT_ONLY); if (AndroidUtils.DEBUG) { Log.d(TAG, "num intents " + list.size()); for (ResolveInfo info : list) { ComponentInfo componentInfo = AndroidUtils.getComponentInfo(info); Log.d(TAG, info.toString() + "/" + (componentInfo == null ? "null" : (componentInfo.name + "/" + componentInfo))); } } startActivity(intent2); if (AndroidUtils.DEBUG) { Log.d(TAG, "Started with" + (intent2.getType() == null ? " no" : " ") + " mime: " + uri); } return true; } catch (Throwable ex2) { if (AndroidUtils.DEBUG) { Log.d(TAG, "no intent for view. " + ex2.toString()); } } } Toast.makeText(getActivity().getApplicationContext(), getActivity().getResources().getString(R.string.intent_security_fail), Toast.LENGTH_LONG) .show(); } catch (android.content.ActivityNotFoundException ex) { if (AndroidUtils.DEBUG) { Log.d(TAG, "no intent for view. " + ex.toString()); } if (mimetype != null) { try { Intent intent2 = new Intent(Intent.ACTION_VIEW, uri); intent2.putExtra("title", name); if (!tryLaunchWithMimeFirst) { intent2.setType(mimetype); } startActivity(intent2); if (AndroidUtils.DEBUG) { Log.d(TAG, "Started (no mime set) " + uri); } return true; } catch (android.content.ActivityNotFoundException ex2) { if (AndroidUtils.DEBUG) { Log.d(TAG, "no intent for view. " + ex2.toString()); } } } Toast.makeText(getActivity().getApplicationContext(), getActivity().getResources().getString(R.string.no_intent), Toast.LENGTH_SHORT).show(); } return true; } return true; }