List of usage examples for android.app Activity startActivity
@Override public void startActivity(Intent intent)
From source file:com.github.fi3te.iliasdownloader.controller.Util.java
public static void openFile(File file, Activity forMessages) { if (file != null && forMessages != null && file.isFile()) { String extension = FilenameUtils.getExtension(file.getPath()); if (extension.length() > 0) { try { extension = extension.toLowerCase(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); forMessages.startActivity(intent); } catch (ActivityNotFoundException anfe) { Toast.makeText(forMessages, forMessages.getResources().getString(R.string.unknown_type), Toast.LENGTH_SHORT).show(); }/*w ww. j av a2 s . c o m*/ } } }
From source file:com.amaze.carbonfilemanager.fragments.preference_fragments.Preffrag.java
public static void restartPC(final Activity activity) { if (activity == null) return;/* w ww. j a v a 2 s . c om*/ final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; activity.overridePendingTransition(enter_anim, exit_anim); activity.finish(); activity.overridePendingTransition(enter_anim, exit_anim); activity.startActivity(activity.getIntent()); }
From source file:com.mercandalli.android.apps.files.file.text.FileTextActivity.java
public static void start(@NonNull final Activity activity, final FileModel fileModel, final boolean isOnline) { final Intent intent = new Intent(activity, FileTextActivity.class); intent.putExtra(EXTRA_MODEL_FILE_URL, "" + fileModel.getOnlineUrl()); if (FileTypeModelENUM.FILESPACE.type.equals(fileModel.getType())) { intent.putExtra(EXTRA_MODEL_FILE_ARTICLE_CONTENT_1, "" + fileModel.getContent().getArticle().article_content_1); }//from w w w.j ava2 s.c o m intent.putExtra(EXTRA_MODEL_FILE_ONLINE, isOnline); activity.startActivity(intent); activity.overridePendingTransition(R.anim.left_in, R.anim.left_out); }
From source file:Main.java
/** Launch an email intent if the device is capable. * * @param activity The parent activity (for context) * @param addr The address to email (not the full URI) * @param text The email body// w ww . j av a2 s. c om */ public static void launchEmailIntent(final Activity activity, String addr, String text) { Log.i(LOG_TAG, "Launch email intent from " + activity.getLocalClassName()); // create email intent Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { addr }); emailIntent.setType("text/plain"); // make sure there is an activity which can handle the intent. PackageManager emailpackageManager = activity.getPackageManager(); List<ResolveInfo> emailresolveInfos = emailpackageManager.queryIntentActivities(emailIntent, 0); if (emailresolveInfos.size() > 0) { activity.startActivity(emailIntent); } }
From source file:com.microsoft.rightsmanagement.sampleapp.App.java
/** * Send file.//www. java 2 s .c o m * * @param activity the activity * @param filePath the file path */ static void sendFile(Activity activity, String filePath) { // New intent to open mail client. Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_SEND); if (isPTxtFile(filePath) || isTxt2File(filePath)) { intent.setType("application/octet-stream"); } else { intent.setType("plain/text"); } intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + filePath)); activity.startActivity(Intent.createChooser(intent, "Sending File...")); }
From source file:Main.java
private static AlertDialog showDownloadDialog(final Activity activity, CharSequence stringTitle, CharSequence stringMessage, CharSequence stringButtonYes, CharSequence stringButtonNo, final String uriString) { AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity); downloadDialog.setTitle(stringTitle); downloadDialog.setMessage(stringMessage); downloadDialog.setPositiveButton(stringButtonYes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { Uri uri = Uri.parse(uriString); Intent intent = new Intent(Intent.ACTION_VIEW, uri); activity.startActivity(intent); }/* ww w . j av a2 s.c o m*/ }); downloadDialog.setNegativeButton(stringButtonNo, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { } }); return downloadDialog.show(); }
From source file:Main.java
private static AlertDialog showDownloadDialog(final Activity activity, CharSequence stringTitle, CharSequence stringMessage, CharSequence stringButtonYes, CharSequence stringButtonNo) { AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity); downloadDialog.setTitle(stringTitle); downloadDialog.setMessage(stringMessage); downloadDialog.setPositiveButton(stringButtonYes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { Uri uri = Uri.parse("market://search?q=pname:org.torproject.android"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); activity.startActivity(intent); }/*from w w w . j av a 2 s. c o m*/ }); downloadDialog.setNegativeButton(stringButtonNo, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { } }); return downloadDialog.show(); }
From source file:com.brq.wallet.activity.receive.ReceiveCoinsActivity.java
public static void callMe(Activity currentActivity, Address address, boolean havePrivateKey) { Intent intent = new Intent(currentActivity, ReceiveCoinsActivity.class); intent.putExtra("address", address); intent.putExtra("havePrivateKey", havePrivateKey); intent.putExtra("showIncomingUtxo", false); currentActivity.startActivity(intent); }
From source file:com.dvn.vindecoder.ui.seller.AddDriverActivity.java
public static void displayPromptForEnablingGPS(final Activity activity) { final AlertDialog.Builder builder = new AlertDialog.Builder(activity); final String action = Settings.ACTION_LOCATION_SOURCE_SETTINGS; final String message = "User sucessfully inserted"; builder.setMessage(message).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface d, int id) { activity.startActivity(new Intent(action)); d.dismiss();//from w w w. j ava 2 s.com } }); builder.create().show(); }
From source file:Main.java
/** * Open an URL in a message./*from w ww. ja va 2 s.c o m*/ * * This is intended to mirror the operation of the original * (see android.webkit.CallbackProxy) with one addition of intent flags * "FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET". This improves behavior when sublaunching * other apps via embedded URI's. * * We also use this hook to catch "mailto:" links and handle them locally. * * @param activity parent activity * @param url URL to open * @param senderAccountId if the URL is mailto:, we use this account as the sender. * TODO When MessageCompose implements the account selector, this won't be necessary. * Pass {@link Account#NO_ACCOUNT} to use the default account. * @return true if the URI has successfully been opened. */ public static boolean openUrlInMessage(Activity activity, String url, long senderAccountId) { // hijack mailto: uri's and handle locally //*** //if (url != null && url.toLowerCase().startsWith("mailto:")) { // return MessageCompose.actionCompose(activity, url, senderAccountId); //} // Handle most uri's via intent launch boolean result = false; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.putExtra(Browser.EXTRA_APPLICATION_ID, activity.getPackageName()); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); try { activity.startActivity(intent); result = true; } catch (ActivityNotFoundException ex) { // No applications can handle it. Ignore. } return result; }