List of usage examples for android.content ActivityNotFoundException getLocalizedMessage
public String getLocalizedMessage()
From source file:Main.java
/** * Save a media in the downloads directory and offer to open it with a third party application. * @param activity the activity//from ww w . j a v a 2 s. co m * @param savedMediaPath the media path * @param mimeType the media mime type. */ public static void openMedia(final Activity activity, final String savedMediaPath, final String mimeType) { if ((null != activity) && (null != savedMediaPath)) { activity.runOnUiThread(new Runnable() { @Override public void run() { try { File file = new File(savedMediaPath); Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), mimeType); activity.startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(activity, e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } catch (Exception e) { } } }); } }
From source file:com.vrem.wifianalyzer.about.AboutActivity.java
public void writeReview(@NonNull View view) { String url = "market://details?id=" + BuildConfig.APPLICATION_ID; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); try {//from w w w . j a va2 s . co m startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } }
From source file:com.vrem.wifianalyzer.navigation.items.ExportItem.java
@Override public void activate(@NonNull MainActivity mainActivity, @NonNull MenuItem menuItem, @NonNull NavigationMenu navigationMenu) { String title = getTitle(mainActivity); List<WiFiDetail> wiFiDetails = getWiFiDetails(); if (!dataAvailable(wiFiDetails)) { Toast.makeText(mainActivity, R.string.no_data, Toast.LENGTH_LONG).show(); return;// ww w . ja va 2s. c om } String data = getData(wiFiDetails); Intent intent = createIntent(title, data); Intent chooser = createChooserIntent(intent, title); if (!exportAvailable(mainActivity, chooser)) { Toast.makeText(mainActivity, R.string.export_not_available, Toast.LENGTH_LONG).show(); return; } try { mainActivity.startActivity(chooser); } catch (ActivityNotFoundException e) { Toast.makeText(mainActivity, e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } }
From source file:org.peercast.core.PeerCastFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { PeerCastServiceController controller = getActivity2().getPeerCastServiceController(); ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) item .getMenuInfo();/* ww w .j a v a 2s . c om*/ int type = ExpandableListView.getPackedPositionType(info.packedPosition); int gPos = ExpandableListView.getPackedPositionGroup(info.packedPosition); int cPos = ExpandableListView.getPackedPositionChild(info.packedPosition); Channel ch = (Channel) mListAdapter.getGroup(gPos); switch (item.getItemId()) { case R.id.menu_ch_disconnect: Log.i(TAG, "Disconnect channel: " + ch); controller.disconnectChannel(ch.getChannel_ID()); return true; case R.id.menu_ch_keep: Log.i(TAG, "Keep channel: " + ch); controller.setChannelKeep(ch.getChannel_ID(), !item.isChecked()); return true; case R.id.menu_ch_play: Uri u = getStreamUri(ch); Intent intent = new Intent(Intent.ACTION_VIEW, u); try { showToast(u.toString()); startActivity(intent); } catch (ActivityNotFoundException e) { getActivity2().showAlertDialog(R.string.t_error, e.getLocalizedMessage(), false); } return true; case R.id.menu_ch_bump: Log.i(TAG, "Bump channel: " + ch); controller.bumpChannel(ch.getChannel_ID()); return true; case R.id.menu_svt_disconnect: // Servent svt = (Servent) mListAdapter.getChild(gPos, cPos); Log.i(TAG, "Disconnect servent: " + svt); controller.disconnectServent(svt.getServent_ID()); return true; default: return super.onContextItemSelected(item); } }
From source file:com.hybris.mobile.app.commerce.fragment.StoreDetailsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Store name needed for this fragment if (StringUtils.isBlank(getActivity().getIntent().getStringExtra(IntentConstants.STORE_NAME))) { throw new IllegalArgumentException(); }/*from ww w .j a va2 s . c om*/ // Getting the map fragment if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { mMapFragment = ((MapFragment) (getChildFragmentManager().findFragmentById(R.id.store_details_map))); } if (mMapFragment == null) { mMapFragment = ((MapFragment) (getFragmentManager().findFragmentById(R.id.store_details_map))); } mStoreAddress = (TextView) getView().findViewById(R.id.store_details_address); mStoreName = (TextView) getView().findViewById(R.id.store_details_name); mStoreDistance = (TextView) getView().findViewById(R.id.store_details_distance); mStoreTel = (TextView) getView().findViewById(R.id.store_details_tel); mStoreDirections = (TextView) getView().findViewById(R.id.store_details_directions); mStoreTel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (StringUtils.isNotBlank(mStoreTel.getText())) { try { startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + mStoreTel.getText().toString().replaceAll("[^\\d.]", "")))); } catch (ActivityNotFoundException e) { Log.e(TAG, e.getLocalizedMessage()); } } } }); mStoreHoursMon = (TextView) getView().findViewById(R.id.store_details_monday); mStoreHoursTue = (TextView) getView().findViewById(R.id.store_details_tuesday); mStoreHoursWed = (TextView) getView().findViewById(R.id.store_details_wednesday); mStoreHoursThu = (TextView) getView().findViewById(R.id.store_details_thursday); mStoreHoursFri = (TextView) getView().findViewById(R.id.store_details_friday); mStoreHoursSat = (TextView) getView().findViewById(R.id.store_details_saturday); mStoreHoursSun = (TextView) getView().findViewById(R.id.store_details_sunday); // Store query QueryStore queryStore = new QueryStore(); queryStore.setStoreName(getActivity().getIntent().getStringExtra(IntentConstants.STORE_NAME)); CommerceApplication.getContentServiceHelper().getStore(this, mRequestId, queryStore, false, null, new OnRequestListener() { @Override public void beforeRequest() { UIUtils.showLoadingActionBar(getActivity(), true); getView().findViewById(R.id.store_details_loading).setVisibility(View.VISIBLE); getView().findViewById(R.id.store_details_bloc).setVisibility(View.GONE); } @Override public void afterRequestBeforeResponse() { } @Override public void afterRequest(boolean isDataSynced) { UIUtils.showLoadingActionBar(getActivity(), false); getView().findViewById(R.id.store_details_loading).setVisibility(View.GONE); getView().findViewById(R.id.store_details_bloc).setVisibility(View.VISIBLE); } }); }
From source file:org.dmfs.tasks.SettingsListFragment.java
/** * Is called, when the user click on the settings icon of a list item. This calls the assigned component to edit the list. * //www. j a va2 s. c o m * @param account * The account of the list. * @param listId * The id of the list. * @param name * The name of the list. * @param color * The color of the list. */ private void onEditListClick(Account account, long listId, String name, Integer color) { Model model = mSources.getModel(account.type); if (!model.hasEditActivity()) { return; } try { model.startEditIntent(getActivity(), account, listId, name, color); } catch (ActivityNotFoundException e) { Toast.makeText(getActivity(), "No activity found to edit the list" + e.getLocalizedMessage(), Toast.LENGTH_SHORT).show(); } }
From source file:im.neon.activity.CommonActivityUtils.java
/** * Save a media in the downloads directory and offer to open it with a third party application. * * @param activity the activity//from w w w . j ava 2 s . c o m * @param savedMediaPath the media path * @param mimeType the media mime type. */ public static void openMedia(final Activity activity, final String savedMediaPath, final String mimeType) { if ((null != activity) && (null != savedMediaPath)) { activity.runOnUiThread(new Runnable() { @Override public void run() { try { File file = new File(savedMediaPath); Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), mimeType); activity.startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(activity, e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } catch (Exception e) { Log.d(LOG_TAG, "## openMedia(): Exception Msg=" + e.getMessage()); } } }); } }