List of usage examples for android.app Fragment getActivity
final public Activity getActivity()
From source file:cis350.blanket.IntentIntegrator.java
/** * @param fragment {@link Fragment} invoking the integration. * {@link #startActivityForResult(Intent, int)} will be called on the {@link Fragment} instead * of an {@link Activity}/* www . j a v a 2s.co m*/ */ public static IntentIntegrator forSupportFragment(android.support.v4.app.Fragment fragment) { IntentIntegrator integrator = new IntentIntegrator(fragment.getActivity()); integrator.supportFragment = fragment; return integrator; }
From source file:org.alfresco.mobile.android.application.manager.ActionManager.java
/** * Open a local file with a 3rd party application. Manage automatically with * Data Protection./*w w w. j a va2s . c om*/ * * @param fr * @param myFile * @param listener */ public static void actionView(Fragment fr, File myFile, ActionManagerListener listener) { try { String mimeType = MimeTypeManager.getMIMEType(fr.getActivity(), myFile.getName()); if (ApplicationManager.getSamsungManager(fr.getActivity()) != null && ApplicationManager.getSamsungManager(fr.getActivity()).hasPenEnable() && (mimeType == null || mimeType.equals("application/octet-stream")) && MimeTypeManager .getExtension(myFile.getName()).equals(SamsungManager.SAMSUNG_NOTE_EXTENSION_SPD)) { mimeType = SamsungManager.SAMSUNG_NOTE_MIMETYPE; } if (DataProtectionManager.getInstance(fr.getActivity()).isEncrypted(myFile.getPath())) { WaitingDialogFragment dialog = WaitingDialogFragment.newInstance(R.string.data_protection, R.string.decryption_title, true); dialog.show(fr.getActivity().getFragmentManager(), WaitingDialogFragment.TAG); DataProtectionManager.getInstance(fr.getActivity()).decrypt( SessionUtils.getAccount(fr.getActivity()), myFile, DataProtectionManager.ACTION_VIEW); } else { actionView(fr.getActivity(), myFile, mimeType, listener); } } catch (Exception e) { MessengerManager.showToast(fr.getActivity(), R.string.error_unable_open_file); } }
From source file:com.android.packageinstaller.permission.ui.PermissionAppsFragment.java
private static void bindUi(Fragment fragment, PermissionApps permissionApps) { final Drawable icon = permissionApps.getIcon(); final CharSequence label = permissionApps.getLabel(); final ActionBar ab = fragment.getActivity().getActionBar(); if (ab != null) { ab.setTitle(fragment.getString(R.string.permission_title, label)); }/*from w w w . jav a 2 s .c om*/ final ViewGroup rootView = (ViewGroup) fragment.getView(); final ImageView iconView = (ImageView) rootView.findViewById(R.id.lb_icon); if (iconView != null) { // Set the icon as the background instead of the image because ImageView // doesn't properly scale vector drawables beyond their intrinsic size iconView.setBackground(icon); } final TextView titleView = (TextView) rootView.findViewById(R.id.lb_title); if (titleView != null) { titleView.setText(label); } final TextView breadcrumbView = (TextView) rootView.findViewById(R.id.lb_breadcrumb); if (breadcrumbView != null) { breadcrumbView.setText(R.string.app_permissions); } }
From source file:org.alfresco.mobile.android.application.manager.ActionManager.java
public static void actionDisplayError(Fragment f, Exception e) { Intent i = new Intent(IntentIntegrator.ACTION_DISPLAY_ERROR); if (e != null) { i.putExtra(IntentIntegrator.EXTRA_ERROR_DATA, e); }//from w ww . jav a 2 s .com LocalBroadcastManager.getInstance(f.getActivity()).sendBroadcast(i); }
From source file:com.hiqes.andele.Andele.java
/** * Helper API to start the Settings app directly into the details page * for the app. This allows the user to quickly change the permissions * granted/denied for the app.//from w w w. ja v a 2 s .c o m * <p> * @param fragment The Fragment in the running state making the request. */ public static void startSettingsApp(Fragment fragment) { startSettingsApp((Context) fragment.getActivity()); }
From source file:com.hiqes.andele.Andele.java
/** * Helper API to start the Settings app directly into the details page * for the app. This allows the user to quickly change the permissions * granted/denied for the app.//from ww w. java 2 s .c om * <p> * @param fragment The Fragment in the running state making the request. */ public static void startSettingsApp(android.support.v4.app.Fragment fragment) { startSettingsApp((Context) fragment.getActivity()); }
From source file:net.sf.diningout.app.ui.FriendsFragment.java
private static void sendInvite(List<String> to, Fragment frag) { Intent intent = new Intent(ACTION_SENDTO, Uris.mailto(to, null, null, frag.getString(R.string.invite_subject), frag.getString(R.string.invite_body))); if (Intents.hasActivity(frag.getActivity(), intent)) { frag.startActivity(intent);// w w w. ja v a 2 s . c o m } }
From source file:de.spiritcroc.modular_remote.Util.java
public static void suggestPreviousIps(final Fragment fragment, final AutoCompleteTextView textView) { Activity activity = fragment.getActivity(); final TcpConnectionManager tcpConnectionManager = TcpConnectionManager .getInstance(activity.getApplicationContext()); textView.setAdapter(new ArrayAdapter<>(activity, android.R.layout.simple_list_item_1, tcpConnectionManager.getConnectionSuggestions())); if (fragment instanceof ReceiverIpSelectorUser) { textView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w w w.java2 s . c om public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TcpConnectionManager.TcpConnection connection = tcpConnectionManager .getTcpConnection(textView.getText().toString()); ((ReceiverIpSelectorUser) fragment).setReceiverType(connection.getType()); } }); } }
From source file:org.alfresco.mobile.android.application.manager.ActionManager.java
/** * Allow to pick file with other apps.//from w ww . j av a 2 s .co m * * @return Activity for Result. */ public static void actionPickFile(Fragment f, int requestCode) { try { Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.setType("*/*"); i.addCategory(Intent.CATEGORY_OPENABLE); f.startActivityForResult(Intent.createChooser(i, f.getText(R.string.content_app_pick_file)), requestCode); } catch (ActivityNotFoundException e) { MessengerManager.showToast(f.getActivity(), R.string.error_unable_open_file); } }
From source file:com.xtremelabs.imageutils.ImageLoader.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public static ImageLoader buildImageLoaderForFragment(Fragment fragment) { return new ImageLoader(fragment, fragment.getActivity()); }