List of usage examples for android.net Uri fromParts
public static Uri fromParts(String scheme, String ssp, String fragment)
From source file:com.github.akinaru.bleremote.menu.MenuUtils.java
/** * Execute actions according to selected menu item * * @param menuItem MenuItem object/* w w w . ja v a 2s .c o m*/ * @param mDrawer navigation drawer * @param context android context */ public static void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context, IRemoteActivity remoteActivity) { switch (menuItem.getItemId()) { case R.id.disconnect_device: { if (remoteActivity != null) { remoteActivity.disconnect(); } break; } case R.id.report_bugs: { Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", context.getResources().getString(R.string.email_addr), null)); intent.putExtra(Intent.EXTRA_SUBJECT, context.getResources().getString(R.string.issue_subject)); intent.putExtra(Intent.EXTRA_TEXT, context.getResources().getString(R.string.report_hint)); context.startActivity( Intent.createChooser(intent, context.getResources().getString(R.string.issue_title))); break; } case R.id.open_source_components: { OpenSourceItemsDialog d = new OpenSourceItemsDialog(context); d.show(); break; } case R.id.about_app: { AboutDialog dialog = new AboutDialog(context); dialog.show(); break; } } mDrawer.closeDrawers(); }
From source file:jmri.enginedriver.intro_write_settings.java
@SuppressWarnings("ConstantConditions") @Override// w w w. j av a2s . c o m public void onActivityCreated(@Nullable Bundle savedInstanceState) { Log.d("Engine_Driver", "intro_write_settings"); super.onActivityCreated(savedInstanceState); Button settingsButton = getView().findViewById(R.id.intro_write_settings_launch); settingsButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Settings.ACTION_MANAGE_WRITE_SETTINGS); Uri uri = Uri.fromParts("package", getActivity().getApplicationContext().getPackageName(), null); intent.setData(uri); getActivity().startActivity(intent); } }); }
From source file:io.upnext.beaconcontrol.app.LocationPermissionExplainingDialogFragment.java
private void showApplicationSettings() { Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts(URI_SCHEME_PACKAGE, getContext().getPackageName(), null); intent.setData(uri);/*from w w w .j ava 2s .c o m*/ startActivity(intent); }
From source file:dk.kk.cykelsuperstier.reminders.AlarmReceiver.java
private void createNotification(Context context, int repetition) { NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Intent intent = new Intent(context, SplashActivity.class); intent.setData(Uri.fromParts("cykelsuperstier", "custom", "1")); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); String description = CykelPlanenApplication.getString("reminder_alert_text"); builder.setContentIntent(pendingIntent).setSmallIcon(R.drawable.ic_launcher) .setTicker(context.getResources().getString(R.string.app_name) + " " + description) .setWhen(System.currentTimeMillis()).setAutoCancel(true).setContentText(description) .setContentTitle(context.getResources().getString(R.string.app_name)); builder.setStyle(new NotificationCompat.InboxStyle()); Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); if (alarmSound == null) { alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); }//from w w w . ja va 2s .c o m builder.setSound(alarmSound); Notification n = builder.build(); notificationManager.notify(1, n); }
From source file:com.spoiledmilk.cykelsuperstier.reminders.AlarmReceiver.java
private void createNotification(Context context, int repetition) { NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Intent intent = new Intent(context, SplashActivity.class); intent.setData(Uri.fromParts("cykelsuperstier", "custom", "1")); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); String description = CykelsuperstierApplication.getString("reminder_alert_text"); builder.setContentIntent(pendingIntent).setSmallIcon(R.drawable.ic_launcher) .setTicker(context.getResources().getString(R.string.app_name) + " " + description) .setWhen(System.currentTimeMillis()).setAutoCancel(true).setContentText(description) .setContentTitle(context.getResources().getString(R.string.app_name)); builder.setStyle(new NotificationCompat.InboxStyle()); Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); if (alarmSound == null) { alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); }//ww w . j a va 2 s . c o m builder.setSound(alarmSound); Notification n = builder.build(); notificationManager.notify(1, n); }
From source file:com.thelastcrusade.soundstream.components.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_about, container, false); final TextView repoLinkText = (TextView) v.findViewById(R.id.repo_link), SlidingMenuLinkText = (TextView) v.findViewById(R.id.thanks_SlidingMenu), emailLinkText = (TextView) v.findViewById(R.id.email_link); listenToHttpLink(repoLinkText, getString(R.string.repo_link)); listenToHttpLink(SlidingMenuLinkText, getString(R.string.sliding_menu_link)); emailLinkText.setOnClickListener(new AdapterView.OnClickListener() { @Override//from www.ja v a 2s.co m public void onClick(View v) { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", getString(R.string.email_support_address), null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.email_subject_tag)); startActivity(Intent.createChooser(emailIntent, "Send email...")); } }); v.findViewById(R.id.instructions_text).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { new InstructionsDialog(getActivity()).show(); } }); return v; }
From source file:com.github.akinaru.hcidebugger.menu.MenuUtils.java
/** * Execute actions according to selected menu item * * @param menuItem MenuItem object//from w w w. jav a 2s . com * @param mDrawer navigation drawer */ public static void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context, final IHciDebugger activity, IDialog dialogCb) { switch (menuItem.getItemId()) { case R.id.set_max_packet_num: { if (activity != null) { MaxPacketCountDialog dialog = new MaxPacketCountDialog(activity); dialogCb.setCurrentDialog(dialog); dialog.show(); } break; } case R.id.browse_file: { if (activity != null) { SnoopFileDialog dialog = new SnoopFileDialog(activity); dialogCb.setCurrentDialog(dialog); dialog.show(); } break; } case R.id.report_bugs: { Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", context.getResources().getString(R.string.developper_mail), null)); intent.putExtra(Intent.EXTRA_SUBJECT, context.getResources().getString(R.string.issue_object)); intent.putExtra(Intent.EXTRA_TEXT, context.getResources().getString(R.string.issue_message)); context.startActivity( Intent.createChooser(intent, context.getResources().getString(R.string.issue_title))); break; } case R.id.scan_btn_nv: { activity.toggleScan(menuItem); break; } case R.id.reset_snoop_file_nv: { activity.resetSnoopFile(); activity.refresh(); break; } case R.id.state_bt_btn_nv: { activity.toggleBtState(); break; } case R.id.change_settings: { CharSequence[] array = { "Classic/BLE scan", "BLE scan" }; int indexCheck = 0; if (activity.getScanType() == ScanType.BLE_SCAN) { indexCheck = 1; } Dialog dialog = new AlertDialog.Builder(context).setSingleChoiceItems(array, indexCheck, null) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); int selectedPosition = ((AlertDialog) dialog).getListView().getCheckedItemPosition(); if (selectedPosition == 0) { activity.setScanType(ScanType.CLASSIC_SCAN); } else { activity.setScanType(ScanType.BLE_SCAN); } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).show(); dialogCb.setCurrentDialog(dialog); break; } case R.id.open_source_components: { OpenSourceItemsDialog dialog = new OpenSourceItemsDialog(context); dialogCb.setCurrentDialog(dialog); dialog.show(); break; } case R.id.rate_app: { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getApplicationContext().getPackageName()))); break; } case R.id.about_app: { AboutDialog dialog = new AboutDialog(context); dialogCb.setCurrentDialog(dialog); dialog.show(); break; } } mDrawer.closeDrawers(); }
From source file:com.rks.musicx.misc.utils.permissionManager.java
public static void widgetPermission(@NonNull Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(activity)) { MaterialDialog.Builder dialog = new MaterialDialog.Builder(activity).title(R.string.permissions_title) .content(R.string.draw_over_permissions_message).positiveText(R.string.btn_continue) .negativeText(R.string.btn_cancel).autoDismiss(true) .onPositive(new MaterialDialog.SingleButtonCallback() { @Override/*from ww w . java 2s.c o m*/ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.fromParts("package", activity.getPackageName(), null)); if (Helper.isActivityPresent(activity, intent)) { activity.startActivityForResult(intent, OVERLAY_REQ); } else { Toast.makeText(activity, "No app found to handle floating widget enable permission", Toast.LENGTH_SHORT).show(); } } } }).onNegative(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { Toast.makeText(activity, R.string.toast_permissions_not_granted, Toast.LENGTH_SHORT) .show(); dialog.dismiss(); } }).neutralText("Never show again").onNeutral(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { Extras.getInstance().setWidgetTrack(true); dialog.dismiss(); } }); if (activity.hasWindowFocus() || !activity.isFinishing()) { dialog.show(); } } }
From source file:com.hrs.filltheform.main.PermissionsManager.java
public static void openAppSettings(AppCompatActivity activity) { Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", activity.getPackageName(), null); intent.setData(uri);//from w w w.ja v a2 s. c o m activity.startActivity(intent); }
From source file:se.johan.wendler.fragment.AboutFragment.java
/** * Called when a list item is clicked.// w w w .jav a 2 s . c o m */ @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: ChangelogDialog.newInstance().show(getActivity().getSupportFragmentManager(), ChangelogDialog.TAG); break; case 1: Intent sendIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "lolbolljohan@gmail.com", null)); sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.wendlerized) + " " + Utils.getCurrentAppVersion(getActivity()) + " feedback"); startActivity(Intent.createChooser(sendIntent, getString(R.string.send_email_title))); break; case 2: LicensesDialogFragment.newInstance(R.raw.notices, false).show(getActivity().getSupportFragmentManager(), null); break; } }